Patchwork phabricator: better error message when phabread fails to get a differential

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 24, 2019, 11:24 p.m.
Message ID <a39d18493bf66aa29f7d.1553469852@chloe>
Download mbox | patch
Permalink /patch/39376/
State New
Headers show

Comments

Jordi Gutiérrez Hermoso - March 24, 2019, 11:24 p.m.
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1553469818 14400
#      Sun Mar 24 19:23:38 2019 -0400
# Node ID a39d18493bf66aa29f7d0dc1c5a4164b84507e1b
# Parent  ba064f95175e6cb1467401a3a536d8c32229d4b1
phabricator: better error message when phabread fails to get a differential
Yuya Nishihara - March 25, 2019, 10:12 p.m.
On Sun, 24 Mar 2019 19:24:12 -0400, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Laurent Peuch <cortex@worlddomination.be>
> # Date 1553469818 14400
> #      Sun Mar 24 19:23:38 2019 -0400
> # Node ID a39d18493bf66aa29f7d0dc1c5a4164b84507e1b
> # Parent  ba064f95175e6cb1467401a3a536d8c32229d4b1
> phabricator: better error message when phabread fails to get a differential
> 
> diff --git a/hgext/phabricator.py b/hgext/phabricator.py
> --- a/hgext/phabricator.py
> +++ b/hgext/phabricator.py
> @@ -783,8 +783,9 @@ def querydrev(repo, spec):
>              prefetched[drev[b'phid']] = drev
>              prefetched[int(drev[b'id'])] = drev
>          if key not in prefetched:
> -            raise error.Abort(_(b'cannot get Differential Revision %r')
> -                              % params)
> +            raise error.Abort(_(b'cannot get Differential Revision %s using the params %r.'
> +                              % (key, params)),

stringutil.pprint()? Otherwise, py3 would print b''.

> +                              hint=_("check that the Differential Revision exists and that you have access to it"))

test-check-code.t would say hi.

Patch

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -783,8 +783,9 @@  def querydrev(repo, spec):
             prefetched[drev[b'phid']] = drev
             prefetched[int(drev[b'id'])] = drev
         if key not in prefetched:
-            raise error.Abort(_(b'cannot get Differential Revision %r')
-                              % params)
+            raise error.Abort(_(b'cannot get Differential Revision %s using the params %r.'
+                              % (key, params)),
+                              hint=_("check that the Differential Revision exists and that you have access to it"))
         return prefetched[key]
 
     def getstack(topdrevids):
diff --git a/tests/test-phabricator.t b/tests/test-phabricator.t
--- a/tests/test-phabricator.t
+++ b/tests/test-phabricator.t
@@ -28,6 +28,9 @@  this test.
   $ hg phabread --config auth.hgphab.phabtoken=cli-notavalidtoken \
   >  --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head
   abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long.
+  $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4481 | head
+  abort: cannot get Differential Revision 4481 using the params {'ids': [4481]}.
+  (check that the Differential Revision exists and that you have access to it)
 
 Basic phabread:
   $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head