305 repo._topics = None |
306 repo._topics = None |
306 if util.safehasattr(repo, 'names'): |
307 if util.safehasattr(repo, 'names'): |
307 repo.names.addnamespace(namespaces.namespace( |
308 repo.names.addnamespace(namespaces.namespace( |
308 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, |
309 'topics', 'topic', namemap=_namemap, nodemap=_nodemap, |
309 listnames=lambda repo: repo.topics)) |
310 listnames=lambda repo: repo.topics)) |
|
311 # Wrap workingctx extra to return the topic name |
|
312 extensions.wrapfunction(context.workingctx, '__init__', wrapinit) |
|
313 # Wrap changelog.add to drop empty topic |
|
314 extensions.wrapfunction(changelog.changelog, 'add', wrapadd) |
|
315 |
|
316 def wrapinit(orig, self, repo, *args, **kwargs): |
|
317 orig(self, repo, *args, **kwargs) |
|
318 if repo.currenttopic: |
|
319 self._extra[constants.extrakey] = repo.currenttopic |
|
320 else: |
|
321 # Empty key will be dropped from extra by another hack at the changegroup level |
|
322 self._extra[constants.extrakey] = '' |
|
323 |
|
324 def wrapadd(orig, cl, manifest, files, desc, transaction, p1, p2, user, |
|
325 date=None, extra=None): |
|
326 if constants.extrakey in extra and not extra[constants.extrakey]: |
|
327 extra = extra.copy() |
|
328 del extra[constants.extrakey] |
|
329 return orig(cl, manifest, files, desc, transaction, p1, p2, user, |
|
330 date=date, extra=extra) |
310 |
331 |
311 # revset predicates are automatically registered at loading via this symbol |
332 # revset predicates are automatically registered at loading via this symbol |
312 revsetpredicate = topicrevset.revsetpredicate |
333 revsetpredicate = topicrevset.revsetpredicate |
313 |
334 |
314 @command('topics', [ |
335 @command('topics', [ |