Mercurial > hg
comparison hgext/phabricator.py @ 43840:79c0121220e3
phabricator: add a "phabstatus" template keyword
We add a "phabstatus" template keyword, returning an object with "url"
and "status" keys. This is quite similar to "phabreview" template
keyword, but it queries phabricator for each specified revision so it's
going to be slow (as compared to the "phabstatus" show view from
previous changeset).
Differential Revision: https://phab.mercurial-scm.org/D7507
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Thu, 21 Nov 2019 16:54:00 +0100 |
parents | 70060915c3f2 |
children | 74ec6ca0eb75 |
comparison
equal
deleted
inserted
replaced
43839:70060915c3f2 | 43840:79c0121220e3 |
---|---|
1682 | 1682 |
1683 return templateutil.hybriddict({b'url': url, b'id': t,}) | 1683 return templateutil.hybriddict({b'url': url, b'id': t,}) |
1684 return None | 1684 return None |
1685 | 1685 |
1686 | 1686 |
1687 @eh.templatekeyword(b'phabstatus', requires={b'ctx', b'repo', b'ui'}) | |
1688 def template_status(context, mapping): | |
1689 """:phabstatus: String. Status of Phabricator differential. | |
1690 """ | |
1691 ctx = context.resource(mapping, b'ctx') | |
1692 repo = context.resource(mapping, b'repo') | |
1693 ui = context.resource(mapping, b'ui') | |
1694 | |
1695 rev = ctx.rev() | |
1696 try: | |
1697 drevid = getdrevmap(repo, [rev])[rev] | |
1698 except KeyError: | |
1699 return None | |
1700 drevs = callconduit(ui, b'differential.query', {b'ids': [drevid]}) | |
1701 for drev in drevs: | |
1702 if int(drev[b'id']) == drevid: | |
1703 return templateutil.hybriddict( | |
1704 {b'url': drev[b'uri'], b'status': drev[b'statusName'],} | |
1705 ) | |
1706 return None | |
1707 | |
1708 | |
1687 @show.showview(b'phabstatus', csettopic=b'work') | 1709 @show.showview(b'phabstatus', csettopic=b'work') |
1688 def phabstatusshowview(ui, repo, displayer): | 1710 def phabstatusshowview(ui, repo, displayer): |
1689 """Phabricator differiential status""" | 1711 """Phabricator differiential status""" |
1690 revs = repo.revs('sort(_underway(), topo)') | 1712 revs = repo.revs('sort(_underway(), topo)') |
1691 drevmap = getdrevmap(repo, revs) | 1713 drevmap = getdrevmap(repo, revs) |