--- a/hgext3rd/topic/__init__.py Tue Mar 15 17:26:57 2016 +0000
+++ b/hgext3rd/topic/__init__.py Mon Mar 14 18:39:19 2016 +0000
@@ -12,6 +12,7 @@
"""
import functools
import contextlib
+import re
from mercurial.i18n import _
from mercurial import branchmap
@@ -51,7 +52,22 @@
return self.extra().get(constants.extrakey, '')
context.basectx.topic = _contexttopic
+topicrev = re.compile(r'^t\d+$')
+
+
def _namemap(repo, name):
+ if topicrev.match(name):
+ idx = int(name[1:])
+ topic = repo.currenttopic
+ if not topic:
+ raise error.Abort(_('cannot resolve "%s": no active topic') % name)
+ revs = list(stack.getstack(repo, topic))
+ try:
+ r = revs[idx]
+ except IndexError:
+ msg = _('cannot resolve "%s": topic "%s" has only %d changesets')
+ raise error.Abort(msg % (name, topic, len(revs)))
+ return [repo[r].node()]
return [ctx.node() for ctx in
repo.set('not public() and extra(topic, %s)', name)]