contrib/phabricator.py
changeset 33834 6e666cd59879
parent 33833 fb59192b4981
child 33974 45a8cd74de4e
equal deleted inserted replaced
33833:fb59192b4981 33834:6e666cd59879
     7 """simple Phabricator integration
     7 """simple Phabricator integration
     8 
     8 
     9 This extension provides a ``phabsend`` command which sends a stack of
     9 This extension provides a ``phabsend`` command which sends a stack of
    10 changesets to Phabricator without amending commit messages, and a ``phabread``
    10 changesets to Phabricator without amending commit messages, and a ``phabread``
    11 command which prints a stack of revisions in a format suitable
    11 command which prints a stack of revisions in a format suitable
    12 for :hg:`import`.
    12 for :hg:`import`, and a ``phabupdate`` command to update statuses in batch.
    13 
    13 
    14 By default, Phabricator requires ``Test Plan`` which might prevent some
    14 By default, Phabricator requires ``Test Plan`` which might prevent some
    15 changeset from being sent. The requirement could be disabled by changing
    15 changeset from being sent. The requirement could be disabled by changing
    16 ``differential.require-test-plan-field`` config server side.
    16 ``differential.require-test-plan-field`` config server side.
    17 
    17 
   796     """
   796     """
   797     if opts.get('stack'):
   797     if opts.get('stack'):
   798         spec = ':(%s)' % spec
   798         spec = ':(%s)' % spec
   799     drevs = querydrev(repo, spec)
   799     drevs = querydrev(repo, spec)
   800     readpatch(repo, drevs, ui.write)
   800     readpatch(repo, drevs, ui.write)
       
   801 
       
   802 @command('phabupdate',
       
   803          [('', 'accept', False, _('accept revisions')),
       
   804           ('', 'reject', False, _('reject revisions')),
       
   805           ('', 'abandon', False, _('abandon revisions')),
       
   806           ('', 'reclaim', False, _('reclaim revisions')),
       
   807           ('m', 'comment', '', _('comment on the last revision')),
       
   808          ], _('DREVSPEC [OPTIONS]'))
       
   809 def phabupdate(ui, repo, spec, **opts):
       
   810     """update Differential Revision in batch
       
   811 
       
   812     DREVSPEC selects revisions. See :hg:`help phabread` for its usage.
       
   813     """
       
   814     flags = [n for n in 'accept reject abandon reclaim'.split() if opts.get(n)]
       
   815     if len(flags) > 1:
       
   816         raise error.Abort(_('%s cannot be used together') % ', '.join(flags))
       
   817 
       
   818     actions = []
       
   819     for f in flags:
       
   820         actions.append({'type': f, 'value': 'true'})
       
   821 
       
   822     drevs = querydrev(repo, spec)
       
   823     for i, drev in enumerate(drevs):
       
   824         if i + 1 == len(drevs) and opts.get('comment'):
       
   825             actions.append({'type': 'comment', 'value': opts['comment']})
       
   826         if actions:
       
   827             params = {'objectIdentifier': drev[r'phid'],
       
   828                       'transactions': actions}
       
   829             callconduit(repo, 'differential.revision.edit', params)