Patchwork D8232: phabricator: add a helper function to convert DREVSPECs to a DREV dict list

login
register
mail settings
Submitter phabricator
Date March 6, 2020, 4:04 p.m.
Message ID <6c9fe16e763d8e140be32a4e0f5d4e6d@localhost.localdomain>
Download mbox | patch
Permalink /patch/45552/
State Not Applicable
Headers show

Comments

phabricator - March 6, 2020, 4:04 p.m.
mharbison72 updated this revision to Diff 20557.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8232?vs=20515&id=20557

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8232/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8232

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: Kwan, mercurial-devel

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -1632,6 +1632,27 @@ 
     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'