hgext/phabricator.py
changeset 41073 536beb130f3c
parent 40546 7e2c58b08e74
child 41078 46e0563c67db
equal deleted inserted replaced
41072:72d4a1761fbc 41073:536beb130f3c
   119        b', otherwise will mock all http requests using the specified vcr file.'
   119        b', otherwise will mock all http requests using the specified vcr file.'
   120        b' (ADVANCED)'
   120        b' (ADVANCED)'
   121      )),
   121      )),
   122 ]
   122 ]
   123 
   123 
   124 def vcrcommand(name, flags, spec):
   124 def vcrcommand(name, flags, spec, helpcategory=None):
   125     fullflags = flags + _VCR_FLAGS
   125     fullflags = flags + _VCR_FLAGS
   126     def decorate(fn):
   126     def decorate(fn):
   127         def inner(*args, **kwargs):
   127         def inner(*args, **kwargs):
   128             cassette = kwargs.pop(r'test_vcr', None)
   128             cassette = kwargs.pop(r'test_vcr', None)
   129             if cassette:
   129             if cassette:
   141                     with vcr.use_cassette(cassette):
   141                     with vcr.use_cassette(cassette):
   142                         return fn(*args, **kwargs)
   142                         return fn(*args, **kwargs)
   143             return fn(*args, **kwargs)
   143             return fn(*args, **kwargs)
   144         inner.__name__ = fn.__name__
   144         inner.__name__ = fn.__name__
   145         inner.__doc__ = fn.__doc__
   145         inner.__doc__ = fn.__doc__
   146         return command(name, fullflags, spec)(inner)
   146         return command(name, fullflags, spec, helpcategory=helpcategory)(inner)
   147     return decorate
   147     return decorate
   148 
   148 
   149 def urlencodenested(params):
   149 def urlencodenested(params):
   150     """like urlencode, but works with nested parameters.
   150     """like urlencode, but works with nested parameters.
   151 
   151 
   461 @vcrcommand(b'phabsend',
   461 @vcrcommand(b'phabsend',
   462          [(b'r', b'rev', [], _(b'revisions to send'), _(b'REV')),
   462          [(b'r', b'rev', [], _(b'revisions to send'), _(b'REV')),
   463           (b'', b'amend', True, _(b'update commit messages')),
   463           (b'', b'amend', True, _(b'update commit messages')),
   464           (b'', b'reviewer', [], _(b'specify reviewers')),
   464           (b'', b'reviewer', [], _(b'specify reviewers')),
   465           (b'', b'confirm', None, _(b'ask for confirmation before sending'))],
   465           (b'', b'confirm', None, _(b'ask for confirmation before sending'))],
   466          _(b'REV [OPTIONS]'))
   466          _(b'REV [OPTIONS]'),
       
   467          helpcategory=command.CATEGORY_IMPORT_EXPORT)
   467 def phabsend(ui, repo, *revs, **opts):
   468 def phabsend(ui, repo, *revs, **opts):
   468     """upload changesets to Phabricator
   469     """upload changesets to Phabricator
   469 
   470 
   470     If there are multiple revisions specified, they will be send as a stack
   471     If there are multiple revisions specified, they will be send as a stack
   471     with a linear dependencies relationship using the order specified by the
   472     with a linear dependencies relationship using the order specified by the
   915         content = b'%s%s\n%s' % (header, desc, body)
   916         content = b'%s%s\n%s' % (header, desc, body)
   916         write(encoding.unitolocal(content))
   917         write(encoding.unitolocal(content))
   917 
   918 
   918 @vcrcommand(b'phabread',
   919 @vcrcommand(b'phabread',
   919          [(b'', b'stack', False, _(b'read dependencies'))],
   920          [(b'', b'stack', False, _(b'read dependencies'))],
   920          _(b'DREVSPEC [OPTIONS]'))
   921          _(b'DREVSPEC [OPTIONS]'),
       
   922          helpcategory=command.CATEGORY_IMPORT_EXPORT)
   921 def phabread(ui, repo, spec, **opts):
   923 def phabread(ui, repo, spec, **opts):
   922     """print patches from Phabricator suitable for importing
   924     """print patches from Phabricator suitable for importing
   923 
   925 
   924     DREVSPEC could be a Differential Revision identity, like ``D123``, or just
   926     DREVSPEC could be a Differential Revision identity, like ``D123``, or just
   925     the number ``123``. It could also have common operators like ``+``, ``-``,
   927     the number ``123``. It could also have common operators like ``+``, ``-``,
   946          [(b'', b'accept', False, _(b'accept revisions')),
   948          [(b'', b'accept', False, _(b'accept revisions')),
   947           (b'', b'reject', False, _(b'reject revisions')),
   949           (b'', b'reject', False, _(b'reject revisions')),
   948           (b'', b'abandon', False, _(b'abandon revisions')),
   950           (b'', b'abandon', False, _(b'abandon revisions')),
   949           (b'', b'reclaim', False, _(b'reclaim revisions')),
   951           (b'', b'reclaim', False, _(b'reclaim revisions')),
   950           (b'm', b'comment', b'', _(b'comment on the last revision')),
   952           (b'm', b'comment', b'', _(b'comment on the last revision')),
   951           ], _(b'DREVSPEC [OPTIONS]'))
   953           ], _(b'DREVSPEC [OPTIONS]'),
       
   954           helpcategory=command.CATEGORY_IMPORT_EXPORT)
   952 def phabupdate(ui, repo, spec, **opts):
   955 def phabupdate(ui, repo, spec, **opts):
   953     """update Differential Revision in batch
   956     """update Differential Revision in batch
   954 
   957 
   955     DREVSPEC selects revisions. See :hg:`help phabread` for its usage.
   958     DREVSPEC selects revisions. See :hg:`help phabread` for its usage.
   956     """
   959     """