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

login
register
mail settings
Submitter phabricator
Date March 20, 2020, 8:25 a.m.
Message ID <b56925b79e71f8c7a9a38acd86898dc8@localhost.localdomain>
Download mbox | patch
Permalink /patch/45836/
State Not Applicable
Headers show

Comments

phabricator - March 20, 2020, 8:25 a.m.
Closed by commit rHG6d5db16f6195: phabricator: add a helper function to convert DREVSPECs to a DREV dict list (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

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

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, Alphare, pulkit
Cc: Alphare, Kwan, mercurial-devel
Yuya Nishihara - March 20, 2020, 8:35 a.m.
> +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:
              ^^^^^^
Fixed bad argument expansion since I had to rebase this. Please let me
know if that's wrong.
phabricator - March 20, 2020, 8:37 a.m.
yuja added a comment.


  > +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:
  
    ^^^^^^
  
  Fixed bad argument expansion since I had to rebase this. Please let me
  know if that's wrong.

REPOSITORY
  rHG Mercurial

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

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

To: mharbison72, #hg-reviewers, Alphare, pulkit
Cc: yuja, Alphare, Kwan, mercurial-devel
Yuya Nishihara - March 20, 2020, 8:45 a.m.
> > +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:
>               ^^^^^^
> Fixed bad argument expansion since I had to rebase this. Please let me
> know if that's wrong.

Never mind. Maybe `specs` is a list containing a single list, in which case,
the code is valid.
phabricator - March 20, 2020, 8:47 a.m.
yuja added a comment.


  >> +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:
  >
  >   ^^^^^^
  >
  > Fixed bad argument expansion since I had to rebase this. Please let me
  > know if that's wrong.
  
  Never mind. Maybe `specs` is a list containing a single list, in which case,
  the code is valid.

REPOSITORY
  rHG Mercurial

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

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

To: mharbison72, #hg-reviewers, Alphare, pulkit
Cc: yuja, Alphare, 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'