convertbookmark: properly convert stacked bookmarks
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 01 Sep 2017 17:15:55 +0200
changeset 2909 9ce092b17530
parent 2908 95bb27b8918c
child 2910 e0e8e968560a
convertbookmark: properly convert stacked bookmarks We ignores pure descendant when looking for revision to convert. This adds support for cases were a linear stack contains multiple bookmark (or un-bookmarked descendants exists). In this case, some changeset are left orphan, but we'll consider the issue as minor for now.
hgext3rd/topic/__init__.py
tests/test-topic-debugcb.t
--- a/hgext3rd/topic/__init__.py	Fri Sep 01 18:46:10 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Sep 01 17:15:55 2017 +0200
@@ -522,14 +522,13 @@
 CONVERTBOOKREVSET = """
 not public() and (
     ancestors(bookmark(%s))
-    and not (
-        ancestors(
-            head()
-            and not bookmark(%s)
-        )
-        or ancestors(
-            bookmark()
-            and not bookmark(%s)
+    and not ancestors(
+        (
+            (head() and not bookmark(%s))
+            or (bookmark() - bookmark(%s))
+        ) - (
+            descendants(bookmark(%s))
+            - bookmark(%s)
         )
     )
 )
@@ -540,7 +539,7 @@
 
     find all changesets under the bookmark and under that bookmark only.
     """
-    return repo.revs(CONVERTBOOKREVSET, bmark, bmark, bmark)
+    return repo.revs(CONVERTBOOKREVSET, bmark, bmark, bmark, bmark, bmark)
 
 def _applyconvertbmarktopic(ui, repo, revs, old, bmark, tr):
     """apply bookmark convertion to topic
--- a/tests/test-topic-debugcb.t	Fri Sep 01 18:46:10 2017 +0200
+++ b/tests/test-topic-debugcb.t	Fri Sep 01 17:15:55 2017 +0200
@@ -249,21 +249,26 @@
   o  [0:249055fcca50] root
   
 
-XXX: this should bot only put topic 'foo' on 3,4 but also 'bar' on 0,1,2
+XXX: this should  avoid create orphan changesets.
 
   $ hg debugconvertbookmark --all
+  changed topic to "bar" on 2 revisions
   switching to topic foo
   changed topic to "foo" on 2 revisions
 
   $ hg log -G
-  @  [7:b14d13efcfa7] E
+  @  [9:b14d13efcfa7] E
   |    topic: foo
-  o  [6:c89ca6e70978] D
+  o  [8:c89ca6e70978] D
   |    topic: foo
-  o  [3:ac05e0d05d00] C
-  |    bookmark: bar
-  o  [2:10f317d09e78] B
-  |
+  | o  [7:a3ea0dfe6a10] C
+  | |    topic: bar
+  | o  [6:db1bc6aab480] B
+  | |    topic: bar
+  x |  [3:ac05e0d05d00] C
+  | |
+  x |  [2:10f317d09e78] B
+  |/
   o  [1:e34122c9a2bf] A
   |
   o  [0:249055fcca50] root