Mercurial > hg
comparison hgext/phabricator.py @ 42973:24bf7a3d3c30
phabricator: use exthelper to register commands, config, and templates
Differential Revision: https://phab.mercurial-scm.org/D6875
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 24 Sep 2019 22:41:07 -0400 |
parents | 04c6de38734d |
children | 0f90c2d2d7e8 |
comparison
equal
deleted
inserted
replaced
42972:71bb9363818c | 42973:24bf7a3d3c30 |
---|---|
52 from mercurial import ( | 52 from mercurial import ( |
53 cmdutil, | 53 cmdutil, |
54 context, | 54 context, |
55 encoding, | 55 encoding, |
56 error, | 56 error, |
57 exthelper, | |
57 httpconnection as httpconnectionmod, | 58 httpconnection as httpconnectionmod, |
58 mdiff, | 59 mdiff, |
59 obsutil, | 60 obsutil, |
60 parser, | 61 parser, |
61 patch, | 62 patch, |
62 phases, | 63 phases, |
63 pycompat, | 64 pycompat, |
64 registrar, | |
65 scmutil, | 65 scmutil, |
66 smartset, | 66 smartset, |
67 tags, | 67 tags, |
68 templatefilters, | 68 templatefilters, |
69 templateutil, | 69 templateutil, |
79 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | 79 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
80 # be specifying the version(s) of Mercurial they are tested with, or | 80 # be specifying the version(s) of Mercurial they are tested with, or |
81 # leave the attribute unspecified. | 81 # leave the attribute unspecified. |
82 testedwith = 'ships-with-hg-core' | 82 testedwith = 'ships-with-hg-core' |
83 | 83 |
84 cmdtable = {} | 84 eh = exthelper.exthelper() |
85 command = registrar.command(cmdtable) | 85 |
86 | 86 cmdtable = eh.cmdtable |
87 configtable = {} | 87 command = eh.command |
88 configitem = registrar.configitem(configtable) | 88 configtable = eh.configtable |
89 templatekeyword = eh.templatekeyword | |
89 | 90 |
90 # developer config: phabricator.batchsize | 91 # developer config: phabricator.batchsize |
91 configitem(b'phabricator', b'batchsize', | 92 eh.configitem(b'phabricator', b'batchsize', |
92 default=12, | 93 default=12, |
93 ) | 94 ) |
94 configitem(b'phabricator', b'callsign', | 95 eh.configitem(b'phabricator', b'callsign', |
95 default=None, | 96 default=None, |
96 ) | 97 ) |
97 configitem(b'phabricator', b'curlcmd', | 98 eh.configitem(b'phabricator', b'curlcmd', |
98 default=None, | 99 default=None, |
99 ) | 100 ) |
100 # developer config: phabricator.repophid | 101 # developer config: phabricator.repophid |
101 configitem(b'phabricator', b'repophid', | 102 eh.configitem(b'phabricator', b'repophid', |
102 default=None, | 103 default=None, |
103 ) | 104 ) |
104 configitem(b'phabricator', b'url', | 105 eh.configitem(b'phabricator', b'url', |
105 default=None, | 106 default=None, |
106 ) | 107 ) |
107 configitem(b'phabsend', b'confirm', | 108 eh.configitem(b'phabsend', b'confirm', |
108 default=False, | 109 default=False, |
109 ) | 110 ) |
110 | 111 |
111 colortable = { | 112 colortable = { |
112 b'phabricator.action.created': b'green', | 113 b'phabricator.action.created': b'green', |
1062 if actions: | 1063 if actions: |
1063 params = {b'objectIdentifier': drev[b'phid'], | 1064 params = {b'objectIdentifier': drev[b'phid'], |
1064 b'transactions': actions} | 1065 b'transactions': actions} |
1065 callconduit(ui, b'differential.revision.edit', params) | 1066 callconduit(ui, b'differential.revision.edit', params) |
1066 | 1067 |
1067 templatekeyword = registrar.templatekeyword() | 1068 @eh.templatekeyword(b'phabreview', requires={b'ctx'}) |
1068 | |
1069 @templatekeyword(b'phabreview', requires={b'ctx'}) | |
1070 def template_review(context, mapping): | 1069 def template_review(context, mapping): |
1071 """:phabreview: Object describing the review for this changeset. | 1070 """:phabreview: Object describing the review for this changeset. |
1072 Has attributes `url` and `id`. | 1071 Has attributes `url` and `id`. |
1073 """ | 1072 """ |
1074 ctx = context.resource(mapping, b'ctx') | 1073 ctx = context.resource(mapping, b'ctx') |