Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 3281:703e8398ac57
topic: move function wrapping from reposetup to uisetup
Having the function un reposetup means they get wrapped over and over again for
long lived process.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 12 Dec 2017 01:27:12 +0100 |
parents | 8a772f0c54d9 |
children | 4303a46b4167 06a3cb594956 |
comparison
equal
deleted
inserted
replaced
3280:e642bad8174a | 3281:703e8398ac57 |
---|---|
320 except (KeyError, AttributeError): | 320 except (KeyError, AttributeError): |
321 pass | 321 pass |
322 | 322 |
323 cmdutil.summaryhooks.add('topic', summaryhook) | 323 cmdutil.summaryhooks.add('topic', summaryhook) |
324 | 324 |
325 # Wrap workingctx extra to return the topic name | |
326 extensions.wrapfunction(context.workingctx, '__init__', wrapinit) | |
327 # Wrap changelog.add to drop empty topic | |
328 extensions.wrapfunction(changelog.changelog, 'add', wrapadd) | |
325 | 329 |
326 def reposetup(ui, repo): | 330 def reposetup(ui, repo): |
327 if not isinstance(repo, localrepo.localrepository): | 331 if not isinstance(repo, localrepo.localrepository): |
328 return # this can be a peer in the ssh case (puzzling) | 332 return # this can be a peer in the ssh case (puzzling) |
329 | 333 |
481 repo._topics = None | 485 repo._topics = None |
482 if util.safehasattr(repo, 'names'): | 486 if util.safehasattr(repo, 'names'): |
483 repo.names.addnamespace(namespaces.namespace( | 487 repo.names.addnamespace(namespaces.namespace( |
484 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, | 488 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, |
485 listnames=lambda repo: repo.topics)) | 489 listnames=lambda repo: repo.topics)) |
486 # Wrap workingctx extra to return the topic name | |
487 extensions.wrapfunction(context.workingctx, '__init__', wrapinit) | |
488 # Wrap changelog.add to drop empty topic | |
489 extensions.wrapfunction(changelog.changelog, 'add', wrapadd) | |
490 | 490 |
491 def wrapinit(orig, self, repo, *args, **kwargs): | 491 def wrapinit(orig, self, repo, *args, **kwargs): |
492 orig(self, repo, *args, **kwargs) | 492 orig(self, repo, *args, **kwargs) |
493 if getattr(repo, 'currenttopic', ''): | 493 if getattr(repo, 'currenttopic', ''): |
494 self._extra[constants.extrakey] = repo.currenttopic | 494 self._extra[constants.extrakey] = repo.currenttopic |