2525 ),
2626)
2727@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+ )
2835@click .argument ('args' , nargs = - 1 , type = click .UNPROCESSED )
29- def apply_cmd (series_id , args ):
36+ def apply_cmd (series_id , args , deps ):
3037 """Apply series.
3138
3239 Apply a series locally using the 'git-am' command. Any additional ARGS
@@ -35,9 +42,31 @@ def apply_cmd(series_id, args):
3542 LOG .debug ('Applying series: id=%d, args=%s' , series_id , ' ' .join (args ))
3643
3744 series = api .detail ('series' , series_id )
38- mbox = api .download (series ['mbox' ])
3945
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 )
4170
4271
4372@click .command (name = 'download' )
0 commit comments