# HG changeset patch # User Matt Harbison # Date 2020-03-05 16:00:00 # Node ID 90adda73676a74188fca5ed5b07f67c4a964e015 # Parent f8427841c8fcbe678756eb99ab12dc935537378c 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 diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -1632,6 +1632,27 @@ def getdiffmeta(diff): return meta +def _getdrevs(ui, stack, *specs): + """convert user supplied DREVSPECs into "Differential Revision" dicts + + See ``hg help phabread`` for how to specify each DREVSPEC. + """ + if len(*specs) > 0: + + def _formatspec(s): + if stack: + s = b':(%s)' % s + return b'(%s)' % s + + spec = b'+'.join(pycompat.maplist(_formatspec, *specs)) + + drevs = querydrev(ui, spec) + if drevs: + return drevs + + raise error.Abort(_(b"empty DREVSPEC set")) + + def readpatch(ui, drevs, write): """generate plain-text patch readable by 'hg import'