Submitter | phabricator |
---|---|
Date | March 5, 2020, 4:43 p.m. |
Message ID | <differential-rev-PHID-DREV-3inzw4qodl25lfm3akvm-req@mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/45509/ |
State | Superseded |
Headers | show |
Comments
Alphare added a comment. This seems like something that can easily have a few simple unit tests 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 Cc: Alphare, Kwan, mercurial-devel
mharbison72 added a comment.
In D8232#123673 <https://phab.mercurial-scm.org/D8232#123673>, @Alphare wrote:
> This seems like something that can easily have a few simple unit tests
The next patch attempts to provide coverage. I'm not sure how else to test this, because it wants to communicate with the server to resolve these values, so then it needs to be run as a command to hook up with the VCR infrastructure.
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
Cc: Alphare, Kwan, mercurial-devel
Alphare added a comment.
Alphare accepted this revision.
In D8232#123683 <https://phab.mercurial-scm.org/D8232#123683>, @mharbison72 wrote:
> The next patch attempts to provide coverage. I'm not sure how else to test this, because it wants to communicate with the server to resolve these values, so then it needs to be run as a command to hook up with the VCR infrastructure.
I guess that's fine. I just wish we had more unit tests for things like utils that are self-contained (in theory) and not really subject to change.
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
Cc: Alphare, Kwan, mercurial-devel
mharbison72 added a comment. In D8232#124097 <https://phab.mercurial-scm.org/D8232#124097>, @yuja wrote: >>> +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. It looks like a tuple of strings: >>> print('specs type is %s' % type(specs)) specs type is <type 'tuple'> >>> print('specs is %r' % (specs,)) specs is ('D1', 'D2', 'D3') I copied this pattern from somewhere in Mercurial (file patterns look like they're handled in a similar way), but don't remember exactly where at this point. 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'