25
25
),
26
26
)
27
27
@click .argument ('series_id' , type = click .INT )
28
+ @click .option (
29
+ '--deps/--no-deps' ,
30
+ 'deps' ,
31
+ default = False ,
32
+ help = 'Download any dependencies this series may have, and apply them'
33
+ 'first.' ,
34
+ )
28
35
@click .argument ('args' , nargs = - 1 , type = click .UNPROCESSED )
29
- def apply_cmd (series_id , args ):
36
+ def apply_cmd (series_id , args , deps ):
30
37
"""Apply series.
31
38
32
39
Apply a series locally using the 'git-am' command. Any additional ARGS
@@ -35,9 +42,31 @@ def apply_cmd(series_id, args):
35
42
LOG .debug ('Applying series: id=%d, args=%s' , series_id , ' ' .join (args ))
36
43
37
44
series = api .detail ('series' , series_id )
38
- mbox = api .download (series ['mbox' ])
39
45
40
- utils .git_am (mbox , args )
46
+ # .mbox files are applied in the order they appear in this list.
47
+ to_apply = []
48
+
49
+ if deps :
50
+ if dependencies := series .get ('dependencies' ):
51
+ to_apply .extend (
52
+ map (lambda url : api .get (url )['mbox' ], dependencies )
53
+ )
54
+ else :
55
+ # Notify the user that dependency information could not be found.
56
+ LOG .warning (
57
+ "Dependency information was not found for this series."
58
+ )
59
+ LOG .warning (
60
+ "Either dependencies are unsupported by this Patchwork"
61
+ "server or the feature is disabled for this project."
62
+ )
63
+ LOG .warning ("No dependencies will be applied." )
64
+
65
+ to_apply .append (series ['mbox' ])
66
+
67
+ for mbox_url in to_apply :
68
+ mbox = api .download (mbox_url )
69
+ utils .git_am (mbox , args )
41
70
42
71
43
72
@click .command (name = 'download' )
0 commit comments