comparison hgext/phabricator.py @ 44578:90adda73676a

phabricator: add a helper function to convert DREVSPECs to a DREV dict list Prep work for allowing multiple DREVSPECs to various commands, and properly validating the input. Differential Revision: https://phab.mercurial-scm.org/D8232
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 05 Mar 2020 11:00:00 -0500
parents 3aab524a8480
children a7f8c657a3f0
comparison
equal deleted inserted replaced
44577:f8427841c8fc 44578:90adda73676a
1630 if b'parent' not in meta and diff.get(b'sourceControlBaseRevision'): 1630 if b'parent' not in meta and diff.get(b'sourceControlBaseRevision'):
1631 meta[b'parent'] = diff[b'sourceControlBaseRevision'] 1631 meta[b'parent'] = diff[b'sourceControlBaseRevision']
1632 return meta 1632 return meta
1633 1633
1634 1634
1635 def _getdrevs(ui, stack, *specs):
1636 """convert user supplied DREVSPECs into "Differential Revision" dicts
1637
1638 See ``hg help phabread`` for how to specify each DREVSPEC.
1639 """
1640 if len(*specs) > 0:
1641
1642 def _formatspec(s):
1643 if stack:
1644 s = b':(%s)' % s
1645 return b'(%s)' % s
1646
1647 spec = b'+'.join(pycompat.maplist(_formatspec, *specs))
1648
1649 drevs = querydrev(ui, spec)
1650 if drevs:
1651 return drevs
1652
1653 raise error.Abort(_(b"empty DREVSPEC set"))
1654
1655
1635 def readpatch(ui, drevs, write): 1656 def readpatch(ui, drevs, write):
1636 """generate plain-text patch readable by 'hg import' 1657 """generate plain-text patch readable by 'hg import'
1637 1658
1638 write takes a list of (DREV, bytes), where DREV is the differential number 1659 write takes a list of (DREV, bytes), where DREV is the differential number
1639 (as bytes, without the "D" prefix) and the bytes are the text of a patch 1660 (as bytes, without the "D" prefix) and the bytes are the text of a patch