@@ -109,7 +109,7 @@ def show_cmd(patch_id):
109
109
110
110
111
111
@click .command (name = 'update' )
112
- @click .argument ('patch_id ' , type = click .INT )
112
+ @click .argument ('patch_ids ' , type = click .INT , nargs = - 1 , required = True )
113
113
@click .option ('--commit-ref' , metavar = 'COMMIT_REF' ,
114
114
help = 'Set the patch commit reference hash' )
115
115
@click .option ('--state' , metavar = 'STATE' ,
@@ -120,40 +120,41 @@ def show_cmd(patch_id):
120
120
'either a username or a user\' s email address.' )
121
121
@click .option ('--archived' , metavar = 'ARCHIVED' , type = click .BOOL ,
122
122
help = 'Set the patch archived state.' )
123
- def update_cmd (patch_id , commit_ref , state , delegate , archived ):
124
- """Update a patch .
123
+ def update_cmd (patch_ids , commit_ref , state , delegate , archived ):
124
+ """Update one or more patches .
125
125
126
- Updates a Patch on the Patchwork instance. Some operations may
126
+ Updates one or more Patches on the Patchwork instance. Some operations may
127
127
require admin or maintainer permissions.
128
128
"""
129
- LOG .info ('Updating patch: id=%d, commit_ref=%s, state=%s, archived=%s' ,
130
- patch_id , commit_ref , state , archived )
129
+ for patch_id in patch_ids :
130
+ LOG .info ('Updating patch: id=%d, commit_ref=%s, state=%s, archived=%s' ,
131
+ patch_id , commit_ref , state , archived )
131
132
132
- if delegate :
133
- users = api .index ('users' , [('q' , delegate )])
134
- if len (users ) == 0 :
135
- LOG .error ('No matching delegates found: %s' , delegate )
136
- sys .exit (1 )
137
- elif len (users ) > 1 :
138
- LOG .error ('More than one delegate found: %s' , delegate )
139
- sys .exit (1 )
133
+ if delegate :
134
+ users = api .index ('users' , [('q' , delegate )])
135
+ if len (users ) == 0 :
136
+ LOG .error ('No matching delegates found: %s' , delegate )
137
+ sys .exit (1 )
138
+ elif len (users ) > 1 :
139
+ LOG .error ('More than one delegate found: %s' , delegate )
140
+ sys .exit (1 )
140
141
141
- delegate = users [0 ]['id' ]
142
+ delegate = users [0 ]['id' ]
142
143
143
- data = {}
144
- for key , value in [('commit_ref' , commit_ref ), ('state' , state ),
145
- ('archived' , archived ), ('delegate' , delegate )]:
146
- if value is None :
147
- continue
144
+ data = {}
145
+ for key , value in [('commit_ref' , commit_ref ), ('state' , state ),
146
+ ('archived' , archived ), ('delegate' , delegate )]:
147
+ if value is None :
148
+ continue
148
149
149
- data [key ] = str (value )
150
+ data [key ] = str (value )
150
151
151
- data = [('commit_ref' , commit_ref ), ('state' , state ),
152
- ('archived' , archived ), ('delegate' , delegate )]
152
+ data = [('commit_ref' , commit_ref ), ('state' , state ),
153
+ ('archived' , archived ), ('delegate' , delegate )]
153
154
154
- patch = api .update ('patches' , patch_id , data )
155
+ patch = api .update ('patches' , patch_id , data )
155
156
156
- _show_patch (patch )
157
+ _show_patch (patch )
157
158
158
159
159
160
# NOTE(stephenfin): The list of default states is populated from Patchwork's
0 commit comments