changeset 41164:43fd1947301d

phabricator: teach {phabreview} to work without --amend There's some possibility of this being wrong (e.g. if the url config was changed). But commit messages can be amended too, so that isn't bulletproof either. Having something seems better than just returning None.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 05 Jan 2019 19:50:30 -0500
parents 0101a35deae2
children a3a24ad10efb
files hgext/phabricator.py tests/test-phabricator.t
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/phabricator.py	Sat Jan 05 15:20:33 2019 -0500
+++ b/hgext/phabricator.py	Sat Jan 05 19:50:30 2019 -0500
@@ -997,3 +997,17 @@
             b'url': m.group(b'url'),
             b'id': b"D{}".format(m.group(b'id')),
         })
+    else:
+        tags = ctx.repo().nodetags(ctx.node())
+        for t in tags:
+            if _differentialrevisiontagre.match(t):
+                url = ctx.repo().ui.config(b'phabricator', b'url')
+                if not url.endswith(b'/'):
+                    url += b'/'
+                url += t
+
+                return templateutil.hybriddict({
+                    b'url': url,
+                    b'id': t,
+                })
+    return None
--- a/tests/test-phabricator.t	Sat Jan 05 15:20:33 2019 -0500
+++ b/tests/test-phabricator.t	Sat Jan 05 19:50:30 2019 -0500
@@ -106,13 +106,13 @@
 Template keywords
   $ hg log -T'{rev} {phabreview|json}\n'
   3 {"id": "D5545", "url": "https://phab.mercurial-scm.org/D5545"}
-  2 null
+  2 {"id": "D5544", "url": "https://phab.mercurial-scm.org/D5544"}
   1 {"id": "D4597", "url": "https://phab.mercurial-scm.org/D4597"}
   0 {"id": "D4596", "url": "https://phab.mercurial-scm.org/D4596"}
 
   $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n'
   3 https://phab.mercurial-scm.org/D5545 D5545
-  2 
+  2 https://phab.mercurial-scm.org/D5544 D5544
   1 https://phab.mercurial-scm.org/D4597 D4597
   0 https://phab.mercurial-scm.org/D4596 D4596