##// END OF EJS Templates
phabricator: allow specifying reviewers on phabsend...
Jun Wu -
r33498:b7a75b9a default
parent child Browse files
Show More
@@ -236,7 +236,8 b' def writediffproperties(ctx, diff):'
236 236 }
237 237 callconduit(ctx.repo(), 'differential.setdiffproperty', params)
238 238
239 def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None):
239 def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None,
240 actions=None):
240 241 """create or update a Differential Revision
241 242
242 243 If revid is None, create a new Differential Revision, otherwise update
@@ -244,6 +245,8 b' def createdifferentialrevision(ctx, revi'
244 245
245 246 If oldnode is not None, check if the patch content (without commit message
246 247 and metadata) has changed before creating another diff.
248
249 If actions is not None, they will be appended to the transaction.
247 250 """
248 251 repo = ctx.repo()
249 252 if oldnode:
@@ -268,6 +271,9 b' def createdifferentialrevision(ctx, revi'
268 271 transactions += [{'type': 'summary', 'value': summary},
269 272 {'type': 'summary', 'value': ' '}]
270 273
274 if actions:
275 transactions += actions
276
271 277 # Parse commit message and update related fields.
272 278 desc = ctx.description()
273 279 info = callconduit(repo, 'differential.parsecommitmessage',
@@ -287,8 +293,23 b' def createdifferentialrevision(ctx, revi'
287 293
288 294 return revision
289 295
296 def userphids(repo, names):
297 """convert user names to PHIDs"""
298 query = {'constraints': {'usernames': names}}
299 result = callconduit(repo, 'user.search', query)
300 # username not found is not an error of the API. So check if we have missed
301 # some names here.
302 data = result[r'data']
303 resolved = set(entry[r'fields'][r'username'] for entry in data)
304 unresolved = set(names) - resolved
305 if unresolved:
306 raise error.Abort(_('unknown username: %s')
307 % ' '.join(sorted(unresolved)))
308 return [entry[r'phid'] for entry in data]
309
290 310 @command('phabsend',
291 [('r', 'rev', [], _('revisions to send'), _('REV'))],
311 [('r', 'rev', [], _('revisions to send'), _('REV')),
312 ('', 'reviewer', [], _('specify reviewers'))],
292 313 _('REV [OPTIONS]'))
293 314 def phabsend(ui, repo, *revs, **opts):
294 315 """upload changesets to Phabricator
@@ -308,6 +329,12 b' def phabsend(ui, repo, *revs, **opts):'
308 329 if not revs:
309 330 raise error.Abort(_('phabsend requires at least one changeset'))
310 331
332 actions = []
333 reviewers = opts.get('reviewer', [])
334 if reviewers:
335 phids = userphids(repo, reviewers)
336 actions.append({'type': 'reviewers.add', 'value': phids})
337
311 338 oldnodedrev = getoldnodedrevmap(repo, [repo[r].node() for r in revs])
312 339
313 340 # Send patches one by one so we know their Differential Revision IDs and
@@ -322,7 +349,7 b' def phabsend(ui, repo, *revs, **opts):'
322 349 if oldnode != ctx.node():
323 350 # Create or update Differential Revision
324 351 revision = createdifferentialrevision(ctx, revid, lastrevid,
325 oldnode)
352 oldnode, actions)
326 353 newrevid = int(revision[r'object'][r'id'])
327 354 if revid:
328 355 action = _('updated')
General Comments 0
You need to be logged in to leave comments. Login now