diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -1682,6 +1682,28 @@ return None +@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 + + phabstatus_tmpl = ( b'{label("changeset.{phase}{if(troubles, \' changeset.troubled\')}", ' b'shortest(node, 5))} '