hgext3rd/topic/__init__.py
changeset 3578 10c3e69bb5bf
parent 3449 4a1dc4854648
parent 3534 cd4db75413a2
child 3584 23f701c1cfcb
--- a/hgext3rd/topic/__init__.py	Tue Mar 20 18:41:31 2018 +0530
+++ b/hgext3rd/topic/__init__.py	Wed Mar 21 15:24:51 2018 +0100
@@ -134,13 +134,14 @@
 from . import (
     compat,
     constants,
+    destination,
+    discovery,
+    evolvebits,
     flow,
+    randomname,
     revset as topicrevset,
-    destination,
     stack,
     topicmap,
-    discovery,
-    randomname
 )
 
 if util.safehasattr(registrar, 'command'):
@@ -240,6 +241,12 @@
     revlist = stack.stack(self._repo, topic=topic)
     try:
         return revlist.index(self.rev())
+    except ValueError:
+        if self.obsolete():
+            succ = evolvebits._singlesuccessor(self._repo, self)
+            if succ not in revlist:
+                return None
+            return revlist.index(succ)
     except IndexError:
         # Lets move to the last ctx of the current topic
         return None