hgext/phabricator.py
changeset 44579 a7f8c657a3f0
parent 44578 90adda73676a
child 44585 2d63a8910db6
equal deleted inserted replaced
44578:90adda73676a 44579:a7f8c657a3f0
  1692 
  1692 
  1693 
  1693 
  1694 @vcrcommand(
  1694 @vcrcommand(
  1695     b'phabread',
  1695     b'phabread',
  1696     [(b'', b'stack', False, _(b'read dependencies'))],
  1696     [(b'', b'stack', False, _(b'read dependencies'))],
  1697     _(b'DREVSPEC [OPTIONS]'),
  1697     _(b'DREVSPEC... [OPTIONS]'),
  1698     helpcategory=command.CATEGORY_IMPORT_EXPORT,
  1698     helpcategory=command.CATEGORY_IMPORT_EXPORT,
  1699     optionalrepo=True,
  1699     optionalrepo=True,
  1700 )
  1700 )
  1701 def phabread(ui, repo, spec, **opts):
  1701 def phabread(ui, repo, *specs, **opts):
  1702     """print patches from Phabricator suitable for importing
  1702     """print patches from Phabricator suitable for importing
  1703 
  1703 
  1704     DREVSPEC could be a Differential Revision identity, like ``D123``, or just
  1704     DREVSPEC could be a Differential Revision identity, like ``D123``, or just
  1705     the number ``123``. It could also have common operators like ``+``, ``-``,
  1705     the number ``123``. It could also have common operators like ``+``, ``-``,
  1706     ``&``, ``(``, ``)`` for complex queries. Prefix ``:`` could be used to
  1706     ``&``, ``(``, ``)`` for complex queries. Prefix ``:`` could be used to
  1707     select a stack.
  1707     select a stack.  If multiple DREVSPEC values are given, the result is the
       
  1708     union of each individually evaluated value.  No attempt is currently made
       
  1709     to reorder the values to run from parent to child.
  1708 
  1710 
  1709     ``abandoned``, ``accepted``, ``closed``, ``needsreview``, ``needsrevision``
  1711     ``abandoned``, ``accepted``, ``closed``, ``needsreview``, ``needsrevision``
  1710     could be used to filter patches by status. For performance reason, they
  1712     could be used to filter patches by status. For performance reason, they
  1711     only represent a subset of non-status selections and cannot be used alone.
  1713     only represent a subset of non-status selections and cannot be used alone.
  1712 
  1714 
  1716 
  1718 
  1717     If --stack is given, follow dependencies information and read all patches.
  1719     If --stack is given, follow dependencies information and read all patches.
  1718     It is equivalent to the ``:`` operator.
  1720     It is equivalent to the ``:`` operator.
  1719     """
  1721     """
  1720     opts = pycompat.byteskwargs(opts)
  1722     opts = pycompat.byteskwargs(opts)
  1721     if opts.get(b'stack'):
  1723     drevs = _getdrevs(ui, opts.get(b'stack'), specs)
  1722         spec = b':(%s)' % spec
       
  1723     drevs = querydrev(ui, spec)
       
  1724 
  1724 
  1725     def _write(patches):
  1725     def _write(patches):
  1726         for drev, content in patches:
  1726         for drev, content in patches:
  1727             ui.write(content)
  1727             ui.write(content)
  1728 
  1728 
  1730 
  1730 
  1731 
  1731 
  1732 @vcrcommand(
  1732 @vcrcommand(
  1733     b'phabimport',
  1733     b'phabimport',
  1734     [(b'', b'stack', False, _(b'import dependencies as well'))],
  1734     [(b'', b'stack', False, _(b'import dependencies as well'))],
  1735     _(b'DREVSPEC [OPTIONS]'),
  1735     _(b'DREVSPEC... [OPTIONS]'),
  1736     helpcategory=command.CATEGORY_IMPORT_EXPORT,
  1736     helpcategory=command.CATEGORY_IMPORT_EXPORT,
  1737 )
  1737 )
  1738 def phabimport(ui, repo, spec, **opts):
  1738 def phabimport(ui, repo, *specs, **opts):
  1739     """import patches from Phabricator for the specified Differential Revisions
  1739     """import patches from Phabricator for the specified Differential Revisions
  1740 
  1740 
  1741     The patches are read and applied starting at the parent of the working
  1741     The patches are read and applied starting at the parent of the working
  1742     directory.
  1742     directory.
  1743 
  1743 
  1783                         raise error.Abort(_(b'D%s: no diffs found') % drev)
  1783                         raise error.Abort(_(b'D%s: no diffs found') % drev)
  1784 
  1784 
  1785                     ui.note(msg + b'\n')
  1785                     ui.note(msg + b'\n')
  1786                     parents = [repo[node]]
  1786                     parents = [repo[node]]
  1787 
  1787 
  1788     if opts.get(b'stack'):
  1788     drevs = _getdrevs(ui, opts.get(b'stack'), specs)
  1789         spec = b':(%s)' % spec
       
  1790     drevs = querydrev(repo.ui, spec)
       
  1791 
  1789 
  1792     readpatch(repo.ui, drevs, _write)
  1790     readpatch(repo.ui, drevs, _write)
  1793 
  1791 
  1794 
  1792 
  1795 @vcrcommand(
  1793 @vcrcommand(
  1799         (b'', b'reject', False, _(b'reject revisions')),
  1797         (b'', b'reject', False, _(b'reject revisions')),
  1800         (b'', b'abandon', False, _(b'abandon revisions')),
  1798         (b'', b'abandon', False, _(b'abandon revisions')),
  1801         (b'', b'reclaim', False, _(b'reclaim revisions')),
  1799         (b'', b'reclaim', False, _(b'reclaim revisions')),
  1802         (b'm', b'comment', b'', _(b'comment on the last revision')),
  1800         (b'm', b'comment', b'', _(b'comment on the last revision')),
  1803     ],
  1801     ],
  1804     _(b'DREVSPEC [OPTIONS]'),
  1802     _(b'DREVSPEC... [OPTIONS]'),
  1805     helpcategory=command.CATEGORY_IMPORT_EXPORT,
  1803     helpcategory=command.CATEGORY_IMPORT_EXPORT,
  1806     optionalrepo=True,
  1804     optionalrepo=True,
  1807 )
  1805 )
  1808 def phabupdate(ui, repo, spec, **opts):
  1806 def phabupdate(ui, repo, *specs, **opts):
  1809     """update Differential Revision in batch
  1807     """update Differential Revision in batch
  1810 
  1808 
  1811     DREVSPEC selects revisions. See :hg:`help phabread` for its usage.
  1809     DREVSPEC selects revisions. See :hg:`help phabread` for its usage.
  1812     """
  1810     """
  1813     opts = pycompat.byteskwargs(opts)
  1811     opts = pycompat.byteskwargs(opts)
  1817 
  1815 
  1818     actions = []
  1816     actions = []
  1819     for f in flags:
  1817     for f in flags:
  1820         actions.append({b'type': f, b'value': True})
  1818         actions.append({b'type': f, b'value': True})
  1821 
  1819 
  1822     drevs = querydrev(ui, spec)
  1820     drevs = _getdrevs(ui, opts.get(b'stack'), specs)
  1823     for i, drev in enumerate(drevs):
  1821     for i, drev in enumerate(drevs):
  1824         if i + 1 == len(drevs) and opts.get(b'comment'):
  1822         if i + 1 == len(drevs) and opts.get(b'comment'):
  1825             actions.append({b'type': b'comment', b'value': opts[b'comment']})
  1823             actions.append({b'type': b'comment', b'value': opts[b'comment']})
  1826         if actions:
  1824         if actions:
  1827             params = {
  1825             params = {