D7507: phabricator: add a "phabstatus" template keyword

dlax (Denis Laxalde) phabricator at mercurial-scm.org
Tue Dec 10 14:46:20 EST 2019


dlax updated this revision to Diff 18590.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7507?vs=18321&id=18590

BRANCH
  default

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

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

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -1684,6 +1684,28 @@
     return None
 
 
+ at eh.templatekeyword(b'phabstatus', requires={b'ctx', b'repo', b'ui'})
+def template_status(context, mapping):
+    """:phabstatus: String. Status of Phabricator differential.
+    """
+    ctx = context.resource(mapping, b'ctx')
+    repo = context.resource(mapping, b'repo')
+    ui = context.resource(mapping, b'ui')
+
+    rev = ctx.rev()
+    try:
+        drevid = getdrevmap(repo, [rev])[rev]
+    except KeyError:
+        return None
+    drevs = callconduit(ui, b'differential.query', {b'ids': [drevid]})
+    for drev in drevs:
+        if int(drev[b'id']) == drevid:
+            return templateutil.hybriddict(
+                {b'url': drev[b'uri'], b'status': drev[b'statusName'],}
+            )
+    return None
+
+
 @show.showview(b'phabstatus', csettopic=b'work')
 def phabstatusshowview(ui, repo, displayer):
     """Phabricator differiential status"""



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


More information about the Mercurial-devel mailing list