# HG changeset patch # User Pierre-Yves David # Date 1504278955 -7200 # Node ID 9ce092b17530401eb66a5a6bdc3c478111660910 # Parent 95bb27b8918c44ad8052523fc002bbfd11b861ad 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. diff -r 95bb27b8918c -r 9ce092b17530 hgext3rd/topic/__init__.py --- 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 diff -r 95bb27b8918c -r 9ce092b17530 tests/test-topic-debugcb.t --- 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