Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 4000:0a05d1b98ccc
branching: merge with stable
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 21 Aug 2018 15:32:02 +0200 |
parents | 52e109e46d78 9f8b99b3d9b5 |
children | 36225eb4d307 |
comparison
equal
deleted
inserted
replaced
3999:52e109e46d78 | 4000:0a05d1b98ccc |
---|---|
130 patch, | 130 patch, |
131 phases, | 131 phases, |
132 registrar, | 132 registrar, |
133 scmutil, | 133 scmutil, |
134 templatefilters, | 134 templatefilters, |
135 templatekw, | |
136 util, | 135 util, |
137 ) | 136 ) |
138 | 137 |
139 from . import ( | 138 from . import ( |
140 compat, | 139 compat, |
147 revset as topicrevset, | 146 revset as topicrevset, |
148 stack, | 147 stack, |
149 topicmap, | 148 topicmap, |
150 ) | 149 ) |
151 | 150 |
152 if util.safehasattr(registrar, 'command'): | |
153 commandfunc = registrar.command | |
154 else: # compat with hg < 4.3 | |
155 commandfunc = cmdutil.command | |
156 | |
157 cmdtable = {} | 151 cmdtable = {} |
158 command = commandfunc(cmdtable) | 152 command = registrar.command(cmdtable) |
159 colortable = {'topic.active': 'green', | 153 colortable = {'topic.active': 'green', |
160 'topic.list.troubledcount': 'red', | 154 'topic.list.troubledcount': 'red', |
161 'topic.list.headcount.multiple': 'yellow', | 155 'topic.list.headcount.multiple': 'yellow', |
162 'topic.list.behindcount': 'cyan', | 156 'topic.list.behindcount': 'cyan', |
163 'topic.list.behinderror': 'red', | 157 'topic.list.behinderror': 'red', |
179 # (first pick I could think off, update as needed | 173 # (first pick I could think off, update as needed |
180 'log.topic': 'green_background', | 174 'log.topic': 'green_background', |
181 'topic.active': 'green', | 175 'topic.active': 'green', |
182 } | 176 } |
183 | 177 |
184 __version__ = '0.10.1.dev' | 178 __version__ = '0.11.0.dev' |
185 | 179 |
186 testedwith = '4.3.3 4.4.2 4.5.2 4.6.2 4.7' | 180 testedwith = '4.3.3 4.4.2 4.5.2 4.6.2 4.7' |
187 minimumhgversion = '4.3' | 181 minimumhgversion = '4.3' |
188 buglink = 'https://bz.mercurial-scm.org/' | 182 buglink = 'https://bz.mercurial-scm.org/' |
189 | 183 |
228 if ('devel' not in ui._knownconfig | 222 if ('devel' not in ui._knownconfig |
229 or not ui._knownconfig['devel'].get('random')): | 223 or not ui._knownconfig['devel'].get('random')): |
230 extraitem('devel', 'randomseed', | 224 extraitem('devel', 'randomseed', |
231 default=None, | 225 default=None, |
232 ) | 226 ) |
227 | |
228 templatekeyword = registrar.templatekeyword() | |
233 | 229 |
234 def _contexttopic(self, force=False): | 230 def _contexttopic(self, force=False): |
235 if not (force or self.mutable()): | 231 if not (force or self.mutable()): |
236 return '' | 232 return '' |
237 return self.extra().get(constants.extrakey, '') | 233 return self.extra().get(constants.extrakey, '') |
336 except (KeyError, AttributeError): | 332 except (KeyError, AttributeError): |
337 pass | 333 pass |
338 | 334 |
339 cmdutil.summaryhooks.add('topic', summaryhook) | 335 cmdutil.summaryhooks.add('topic', summaryhook) |
340 | 336 |
341 templatekw.keywords['topic'] = topickw | |
342 # Wrap workingctx extra to return the topic name | 337 # Wrap workingctx extra to return the topic name |
343 extensions.wrapfunction(context.workingctx, '__init__', wrapinit) | 338 extensions.wrapfunction(context.workingctx, '__init__', wrapinit) |
344 # Wrap changelog.add to drop empty topic | 339 # Wrap changelog.add to drop empty topic |
345 extensions.wrapfunction(changelog.changelog, 'add', wrapadd) | 340 extensions.wrapfunction(changelog.changelog, 'add', wrapadd) |
346 | 341 |
508 if util.safehasattr(repo, 'names'): | 503 if util.safehasattr(repo, 'names'): |
509 repo.names.addnamespace(namespaces.namespace( | 504 repo.names.addnamespace(namespaces.namespace( |
510 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, | 505 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, |
511 listnames=lambda repo: repo.topics)) | 506 listnames=lambda repo: repo.topics)) |
512 | 507 |
513 def topickw(**args): | 508 @templatekeyword('topic', requires={'ctx'}) |
509 def topickw(context, mapping): | |
514 """:topic: String. The topic of the changeset""" | 510 """:topic: String. The topic of the changeset""" |
515 return args['ctx'].topic() | 511 ctx = context.resource(mapping, 'ctx') |
512 return ctx.topic() | |
516 | 513 |
517 def wrapinit(orig, self, repo, *args, **kwargs): | 514 def wrapinit(orig, self, repo, *args, **kwargs): |
518 orig(self, repo, *args, **kwargs) | 515 orig(self, repo, *args, **kwargs) |
519 if getattr(repo, 'currenttopic', ''): | 516 if getattr(repo, 'currenttopic', ''): |
520 self._extra[constants.extrakey] = repo.currenttopic | 517 self._extra[constants.extrakey] = repo.currenttopic |