topic: add a 'topicidx()' to context
This will be useful for the `t0` logic in `hg prev`
--- a/hgext3rd/topic/__init__.py Fri Jul 14 02:41:53 2017 +0200
+++ b/hgext3rd/topic/__init__.py Fri Jul 14 02:42:33 2017 +0200
@@ -126,6 +126,19 @@
return ''
return self.extra().get(constants.extrakey, '')
context.basectx.topic = _contexttopic
+def _contexttopicidx(self):
+ topic = self.topic()
+ if not topic:
+ # XXX we might want to include t0 here,
+ # however t0 is related to 'currenttopic' which has no place here.
+ return None
+ revlist = stack.getstack(self._repo, topic=topic)
+ try:
+ return revlist.index(self.rev())
+ except IndexError:
+ # Lets move to the last ctx of the current topic
+ return None
+context.basectx.topicidx = _contexttopicidx
topicrev = re.compile(r'^t\d+$')
branchrev = re.compile(r'^b\d+$')