diff hgext3rd/topic/__init__.py @ 3532:68e99d2c6267 stable

prev: fix the breakage of `hg previous` from obsolete cset This patch fix the breakage of `hg prev` from obsolete changeset when topic is involved. We get the topicidx of it's succesor and proceed.
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 16 Mar 2018 15:01:44 +0530
parents 6565eac61ebf
children cd4db75413a2
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Fri Mar 16 14:59:10 2018 +0530
+++ b/hgext3rd/topic/__init__.py	Fri Mar 16 15:01:44 2018 +0530
@@ -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,10 @@
     revlist = stack.stack(self._repo, topic=topic)
     try:
         return revlist.index(self.rev())
+    except ValueError:
+        if self.obsolete():
+            succ = evolvebits._singlesuccessor(self._repo, self)
+            return revlist.index(succ)
     except IndexError:
         # Lets move to the last ctx of the current topic
         return None