previous: fix behavior on obsolete cset when topic is involved (issue5708) stable
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 16 Mar 2018 15:21:05 +0530
branchstable
changeset 3534 cd4db75413a2
parent 3533 f06c502ce4b7
child 3578 10c3e69bb5bf
previous: fix behavior on obsolete cset when topic is involved (issue5708) This patch fixes the behavior of `hg previous` when done on an obsolete changeset having a successor of different topic. The underlying code is bit messed up, I wanted to split the topic handling to topic extension but I have postponed it to next bug.
CHANGELOG
hgext3rd/topic/__init__.py
tests/test-evolve-topic.t
--- a/CHANGELOG	Fri Mar 16 15:15:17 2018 +0530
+++ b/CHANGELOG	Fri Mar 16 15:21:05 2018 +0530
@@ -7,6 +7,7 @@
   * fold: fix issue related to bookmarks movement (issue5772)
   * amend: take lock before parsing the commit description (issue5266)
   * legacy: respect 'server.bundle1' config if any is set
+  * previous: fix behavior on obsolete rev when topic is involved (issue5708)
 
 7.2.1 --2018-01-20
 -------------------
--- a/hgext3rd/topic/__init__.py	Fri Mar 16 15:15:17 2018 +0530
+++ b/hgext3rd/topic/__init__.py	Fri Mar 16 15:21:05 2018 +0530
@@ -244,6 +244,8 @@
     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
--- a/tests/test-evolve-topic.t	Fri Mar 16 15:15:17 2018 +0530
+++ b/tests/test-evolve-topic.t	Fri Mar 16 15:21:05 2018 +0530
@@ -361,49 +361,8 @@
   $ hg topic bar
 
   $ hg prev
-  ** Unknown exception encountered with possibly-broken third-party extension evolve
-  ** which supports versions 4.4 of Mercurial.
-  ** Please disable evolve and try your action again.
-  ** If that fixes the bug please report it to https://bz.mercurial-scm.org/
-  ** Python 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
-  ** Mercurial Distributed SCM (version 4.5.2+1098-cdc73e5c75af)
-  ** Extensions loaded: rebase, evolve, topic
-  Traceback (most recent call last):
-    File "/tmp/hgtests.PuAW80/install/bin/hg", line 41, in <module>
-      dispatch.run()
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 88, in run
-      status = (dispatch(req) or 0)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 208, in dispatch
-      ret = _runcatch(req)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 349, in _runcatch
-      return _callcatch(ui, _runcatchfunc)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 357, in _callcatch
-      return scmutil.callcatch(ui, func)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/scmutil.py", line 154, in callcatch
-      return func()
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 339, in _runcatchfunc
-      return _dispatch(req)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 943, in _dispatch
-      cmdpats, cmdoptions)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 700, in runcommand
-      ret = _runcommand(ui, options, cmd, d)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 951, in _runcommand
-      return cmdfunc()
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 940, in <lambda>
-      d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/util.py", line 1497, in check
-      return func(*args, **kwargs)
-    File "/home/foobar/repo/mutable-history/hgext3rd/evolve/__init__.py", line 1051, in cmdprevious
-      opts.get('move_bookmark'), topic)
-    File "/home/foobar/repo/mutable-history/hgext3rd/evolve/__init__.py", line 995, in _findprevtarget
-      if currenttopic and topic and _gettopicidx(p1) != 1:
-    File "/home/foobar/repo/mutable-history/hgext3rd/evolve/__init__.py", line 957, in _gettopicidx
-      return getattr(ctx, 'topicidx', lambda: None)()
-    File "/home/foobar/repo/mutable-history/hgext3rd/topic/__init__.py", line 247, in _contexttopicidx
-      return revlist.index(succ)
-    File "/home/foobar/repo/mutable-history/hgext3rd/topic/stack.py", line 95, in index
-      return self.revs.index(item)
-  ValueError: 18 is not in list
+  no parent in topic "bar"
+  (do you want --no-topic)
   [1]
 
 When current topic and obsolete cset topic are same but successor has different
@@ -413,47 +372,5 @@
   switching to topic foo
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg prev
-  ** Unknown exception encountered with possibly-broken third-party extension evolve
-  ** which supports versions 4.4 of Mercurial.
-  ** Please disable evolve and try your action again.
-  ** If that fixes the bug please report it to https://bz.mercurial-scm.org/
-  ** Python 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
-  ** Mercurial Distributed SCM (version 4.5.2+1098-cdc73e5c75af)
-  ** Extensions loaded: rebase, evolve, topic
-  Traceback (most recent call last):
-    File "/tmp/hgtests.PuAW80/install/bin/hg", line 41, in <module>
-      dispatch.run()
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 88, in run
-      status = (dispatch(req) or 0)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 208, in dispatch
-      ret = _runcatch(req)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 349, in _runcatch
-      return _callcatch(ui, _runcatchfunc)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 357, in _callcatch
-      return scmutil.callcatch(ui, func)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/scmutil.py", line 154, in callcatch
-      return func()
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 339, in _runcatchfunc
-      return _dispatch(req)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 943, in _dispatch
-      cmdpats, cmdoptions)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 700, in runcommand
-      ret = _runcommand(ui, options, cmd, d)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 951, in _runcommand
-      return cmdfunc()
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/dispatch.py", line 940, in <lambda>
-      d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
-    File "/tmp/hgtests.PuAW80/install/lib/python/mercurial/util.py", line 1497, in check
-      return func(*args, **kwargs)
-    File "/home/foobar/repo/mutable-history/hgext3rd/evolve/__init__.py", line 1051, in cmdprevious
-      opts.get('move_bookmark'), topic)
-    File "/home/foobar/repo/mutable-history/hgext3rd/evolve/__init__.py", line 995, in _findprevtarget
-      if currenttopic and topic and _gettopicidx(p1) != 1:
-    File "/home/foobar/repo/mutable-history/hgext3rd/evolve/__init__.py", line 957, in _gettopicidx
-      return getattr(ctx, 'topicidx', lambda: None)()
-    File "/home/foobar/repo/mutable-history/hgext3rd/topic/__init__.py", line 247, in _contexttopicidx
-      return revlist.index(succ)
-    File "/home/foobar/repo/mutable-history/hgext3rd/topic/stack.py", line 95, in index
-      return self.revs.index(item)
-  ValueError: 18 is not in list
-  [1]
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [12] add eee