Mercurial > hg
comparison hgext/phabricator.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 294aab57a5f3 |
children | 57183111a463 |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
106 templatekeyword = eh.templatekeyword | 106 templatekeyword = eh.templatekeyword |
107 uisetup = eh.finaluisetup | 107 uisetup = eh.finaluisetup |
108 | 108 |
109 # developer config: phabricator.batchsize | 109 # developer config: phabricator.batchsize |
110 eh.configitem( | 110 eh.configitem( |
111 b'phabricator', b'batchsize', default=12, | 111 b'phabricator', |
112 b'batchsize', | |
113 default=12, | |
112 ) | 114 ) |
113 eh.configitem( | 115 eh.configitem( |
114 b'phabricator', b'callsign', default=None, | 116 b'phabricator', |
117 b'callsign', | |
118 default=None, | |
115 ) | 119 ) |
116 eh.configitem( | 120 eh.configitem( |
117 b'phabricator', b'curlcmd', default=None, | 121 b'phabricator', |
122 b'curlcmd', | |
123 default=None, | |
118 ) | 124 ) |
119 # developer config: phabricator.debug | 125 # developer config: phabricator.debug |
120 eh.configitem( | 126 eh.configitem( |
121 b'phabricator', b'debug', default=False, | 127 b'phabricator', |
128 b'debug', | |
129 default=False, | |
122 ) | 130 ) |
123 # developer config: phabricator.repophid | 131 # developer config: phabricator.repophid |
124 eh.configitem( | 132 eh.configitem( |
125 b'phabricator', b'repophid', default=None, | 133 b'phabricator', |
134 b'repophid', | |
135 default=None, | |
126 ) | 136 ) |
127 eh.configitem( | 137 eh.configitem( |
128 b'phabricator', b'url', default=None, | 138 b'phabricator', |
139 b'url', | |
140 default=None, | |
129 ) | 141 ) |
130 eh.configitem( | 142 eh.configitem( |
131 b'phabsend', b'confirm', default=False, | 143 b'phabsend', |
144 b'confirm', | |
145 default=False, | |
132 ) | 146 ) |
133 eh.configitem( | 147 eh.configitem( |
134 b'phabimport', b'secret', default=False, | 148 b'phabimport', |
149 b'secret', | |
150 default=False, | |
135 ) | 151 ) |
136 eh.configitem( | 152 eh.configitem( |
137 b'phabimport', b'obsolete', default=False, | 153 b'phabimport', |
154 b'obsolete', | |
155 default=False, | |
138 ) | 156 ) |
139 | 157 |
140 colortable = { | 158 colortable = { |
141 b'phabricator.action.created': b'green', | 159 b'phabricator.action.created': b'green', |
142 b'phabricator.action.skipped': b'magenta', | 160 b'phabricator.action.skipped': b'magenta', |
164 ] | 182 ] |
165 | 183 |
166 | 184 |
167 @eh.wrapfunction(localrepo, "loadhgrc") | 185 @eh.wrapfunction(localrepo, "loadhgrc") |
168 def _loadhgrc(orig, ui, wdirvfs, hgvfs, requirements, *args, **opts): | 186 def _loadhgrc(orig, ui, wdirvfs, hgvfs, requirements, *args, **opts): |
169 """Load ``.arcconfig`` content into a ui instance on repository open. | 187 """Load ``.arcconfig`` content into a ui instance on repository open.""" |
170 """ | |
171 result = False | 188 result = False |
172 arcconfig = {} | 189 arcconfig = {} |
173 | 190 |
174 try: | 191 try: |
175 # json.loads only accepts bytes from 3.6+ | 192 # json.loads only accepts bytes from 3.6+ |
631 BINARY = 3 | 648 BINARY = 3 |
632 | 649 |
633 | 650 |
634 @attr.s | 651 @attr.s |
635 class phabhunk(dict): | 652 class phabhunk(dict): |
636 """Represents a Differential hunk, which is owned by a Differential change | 653 """Represents a Differential hunk, which is owned by a Differential change""" |
637 """ | |
638 | 654 |
639 oldOffset = attr.ib(default=0) # camelcase-required | 655 oldOffset = attr.ib(default=0) # camelcase-required |
640 oldLength = attr.ib(default=0) # camelcase-required | 656 oldLength = attr.ib(default=0) # camelcase-required |
641 newOffset = attr.ib(default=0) # camelcase-required | 657 newOffset = attr.ib(default=0) # camelcase-required |
642 newLength = attr.ib(default=0) # camelcase-required | 658 newLength = attr.ib(default=0) # camelcase-required |
1510 parents = [ | 1526 parents = [ |
1511 mapping.get(old.p1().node(), (old.p1(),))[0], | 1527 mapping.get(old.p1().node(), (old.p1(),))[0], |
1512 mapping.get(old.p2().node(), (old.p2(),))[0], | 1528 mapping.get(old.p2().node(), (old.p2(),))[0], |
1513 ] | 1529 ] |
1514 newdesc = rewriteutil.update_hash_refs( | 1530 newdesc = rewriteutil.update_hash_refs( |
1515 repo, newdesc, mapping, | 1531 repo, |
1532 newdesc, | |
1533 mapping, | |
1516 ) | 1534 ) |
1517 new = context.metadataonlyctx( | 1535 new = context.metadataonlyctx( |
1518 repo, | 1536 repo, |
1519 old, | 1537 old, |
1520 parents=parents, | 1538 parents=parents, |
2225 """ | 2243 """ |
2226 ctx = context.resource(mapping, b'ctx') | 2244 ctx = context.resource(mapping, b'ctx') |
2227 m = _differentialrevisiondescre.search(ctx.description()) | 2245 m = _differentialrevisiondescre.search(ctx.description()) |
2228 if m: | 2246 if m: |
2229 return templateutil.hybriddict( | 2247 return templateutil.hybriddict( |
2230 {b'url': m.group('url'), b'id': b"D%s" % m.group('id'),} | 2248 { |
2249 b'url': m.group('url'), | |
2250 b'id': b"D%s" % m.group('id'), | |
2251 } | |
2231 ) | 2252 ) |
2232 else: | 2253 else: |
2233 tags = ctx.repo().nodetags(ctx.node()) | 2254 tags = ctx.repo().nodetags(ctx.node()) |
2234 for t in tags: | 2255 for t in tags: |
2235 if _differentialrevisiontagre.match(t): | 2256 if _differentialrevisiontagre.match(t): |
2236 url = ctx.repo().ui.config(b'phabricator', b'url') | 2257 url = ctx.repo().ui.config(b'phabricator', b'url') |
2237 if not url.endswith(b'/'): | 2258 if not url.endswith(b'/'): |
2238 url += b'/' | 2259 url += b'/' |
2239 url += t | 2260 url += t |
2240 | 2261 |
2241 return templateutil.hybriddict({b'url': url, b'id': t,}) | 2262 return templateutil.hybriddict( |
2263 { | |
2264 b'url': url, | |
2265 b'id': t, | |
2266 } | |
2267 ) | |
2242 return None | 2268 return None |
2243 | 2269 |
2244 | 2270 |
2245 @eh.templatekeyword(b'phabstatus', requires={b'ctx', b'repo', b'ui'}) | 2271 @eh.templatekeyword(b'phabstatus', requires={b'ctx', b'repo', b'ui'}) |
2246 def template_status(context, mapping): | 2272 def template_status(context, mapping): |
2247 """:phabstatus: String. Status of Phabricator differential. | 2273 """:phabstatus: String. Status of Phabricator differential.""" |
2248 """ | |
2249 ctx = context.resource(mapping, b'ctx') | 2274 ctx = context.resource(mapping, b'ctx') |
2250 repo = context.resource(mapping, b'repo') | 2275 repo = context.resource(mapping, b'repo') |
2251 ui = context.resource(mapping, b'ui') | 2276 ui = context.resource(mapping, b'ui') |
2252 | 2277 |
2253 rev = ctx.rev() | 2278 rev = ctx.rev() |
2257 return None | 2282 return None |
2258 drevs = callconduit(ui, b'differential.query', {b'ids': [drevid]}) | 2283 drevs = callconduit(ui, b'differential.query', {b'ids': [drevid]}) |
2259 for drev in drevs: | 2284 for drev in drevs: |
2260 if int(drev[b'id']) == drevid: | 2285 if int(drev[b'id']) == drevid: |
2261 return templateutil.hybriddict( | 2286 return templateutil.hybriddict( |
2262 {b'url': drev[b'uri'], b'status': drev[b'statusName'],} | 2287 { |
2288 b'url': drev[b'uri'], | |
2289 b'status': drev[b'statusName'], | |
2290 } | |
2263 ) | 2291 ) |
2264 return None | 2292 return None |
2265 | 2293 |
2266 | 2294 |
2267 @show.showview(b'phabstatus', csettopic=b'work') | 2295 @show.showview(b'phabstatus', csettopic=b'work') |