branching: merge stable into default
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 21 Mar 2018 15:24:51 +0100
changeset 3578 10c3e69bb5bf
parent 3577 279d8b610ac5 (current diff)
parent 3534 cd4db75413a2 (diff)
child 3579 3a4552b30ba8
child 3584 23f701c1cfcb
branching: merge stable into default Some bugfix that we could use here (also getting ready for a release).
CHANGELOG
hgext3rd/topic/__init__.py
--- a/CHANGELOG	Tue Mar 20 18:41:31 2018 +0530
+++ b/CHANGELOG	Wed Mar 21 15:24:51 2018 +0100
@@ -18,6 +18,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	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
--- a/tests/test-evolve-topic.t	Tue Mar 20 18:41:31 2018 +0530
+++ b/tests/test-evolve-topic.t	Wed Mar 21 15:24:51 2018 +0100
@@ -268,3 +268,109 @@
   $ hg prev
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   [18] add fff
+
+Testing issue 5708 when we are on obsolete changeset and there is active topic
+------------------------------------------------------------------------------
+
+  $ hg log --graph
+  @  18 - {bar} 793eb6370b2d add fff (draft)
+  |
+  | *  17 - {bar} 9bf430c106b7 add jjj (draft)
+  | |
+  | *  16 - {bar} d2dc89c57700 add iii (draft)
+  | |
+  | *  15 - {bar} 20bc4d02aa62 add hhh (draft)
+  | |
+  | *  14 - {bar} 16d6f664b17c add ggg (draft)
+  | |
+  | x  13 - {foo} 070c5573d8f9 add fff (draft)
+  |/
+  o  12 - {foo} 42b49017ff90 add eee (draft)
+  |
+  o  10 - {foo} d9cacd156ffc add ddd (draft)
+  |
+  o  2 - {foo} cced9bac76e3 add ccc (draft)
+  |
+  o  1 - {} a4dbed0837ea add bbb (draft)
+  |
+  o  0 - {} 199cc73e9a0b add aaa (draft)
+  
+
+  $ hg topic
+   * bar (5 changesets, 4 troubled)
+     foo (3 changesets)
+
+When the current topic, obsoleted changesets topic and successor topic are same
+
+  $ hg up 20bc4d02aa62
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo foobar >> hhh
+  $ hg amend
+  $ hg up 20bc4d02aa62
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory parent is obsolete! (20bc4d02aa62)
+  (use 'hg evolve' to update to its successor: d834582d9ee3)
+  $ hg log -Gr 14::
+  *  19 - {bar} d834582d9ee3 add hhh (draft)
+  |
+  | *  17 - {bar} 9bf430c106b7 add jjj (draft)
+  | |
+  | *  16 - {bar} d2dc89c57700 add iii (draft)
+  | |
+  | @  15 - {bar} 20bc4d02aa62 add hhh (draft)
+  |/
+  *  14 - {bar} 16d6f664b17c add ggg (draft)
+  |
+  ~
+
+  $ hg prev
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [14] add ggg
+
+When the current topic and successors topic are same, but obsolete cset has
+different topic
+
+  $ hg rebase -s d2dc89c57700 -d d834582d9ee3 --config extensions.rebase=
+  rebasing 16:d2dc89c57700 "add iii" (bar)
+  1 new orphan changesets
+  rebasing 17:9bf430c106b7 "add jjj" (bar)
+  1 new orphan changesets
+  $ hg log -Gr 12::
+  *  21 - {bar} 7542e76aba2c add jjj (draft)
+  |
+  *  20 - {bar} 7858bd7e9906 add iii (draft)
+  |
+  *  19 - {bar} d834582d9ee3 add hhh (draft)
+  |
+  | o  18 - {bar} 793eb6370b2d add fff (draft)
+  | |
+  @ |  14 - {bar} 16d6f664b17c add ggg (draft)
+  | |
+  x |  13 - {foo} 070c5573d8f9 add fff (draft)
+  |/
+  o  12 - {foo} 42b49017ff90 add eee (draft)
+  |
+  ~
+
+  $ hg up 070c5573d8f9
+  switching to topic foo
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  working directory parent is obsolete! (070c5573d8f9)
+  (use 'hg evolve' to update to its successor: 793eb6370b2d)
+
+  $ hg topic bar
+
+  $ hg prev
+  no parent in topic "bar"
+  (do you want --no-topic)
+  [1]
+
+When current topic and obsolete cset topic are same but successor has different
+one
+
+  $ hg up 070c5573d8f9
+  switching to topic foo
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg prev
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  [12] add eee