diff hgext3rd/topic/__init__.py @ 3578:10c3e69bb5bf

branching: merge stable into default Some bugfix that we could use here (also getting ready for a release).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 21 Mar 2018 15:24:51 +0100
parents 4a1dc4854648 cd4db75413a2
children 23f701c1cfcb
line wrap: on
line diff
--- 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