rebase: delete divergent bookmarks on destination (
issue3685)
Similar to merge, divergent bookmarks are only deleted when the bookmark is on
the destination parent.
--- a/hgext/rebase.py Wed Jan 30 15:35:00 2013 -0800
+++ b/hgext/rebase.py Wed Jan 30 16:08:32 2013 -0800
@@ -316,7 +316,7 @@
clearrebased(ui, repo, state, skipped, collapsedas)
if currentbookmarks:
- updatebookmarks(repo, nstate, currentbookmarks, **opts)
+ updatebookmarks(repo, dest, nstate, currentbookmarks)
clearstatus(repo)
ui.note(_("rebase completed\n"))
@@ -493,13 +493,15 @@
mq.seriesdirty = True
mq.savedirty()
-def updatebookmarks(repo, nstate, originalbookmarks, **opts):
- 'Move bookmarks to their correct changesets'
+def updatebookmarks(repo, dest, nstate, originalbookmarks):
+ 'Move bookmarks to their correct changesets, and delete divergent ones'
+ destnode = dest.node()
marks = repo._bookmarks
for k, v in originalbookmarks.iteritems():
if v in nstate:
# update the bookmarks for revs that have moved
marks[k] = nstate[v]
+ bookmarks.deletedivergent(repo, [destnode], k)
marks.write()
--- a/tests/test-rebase-bookmarks.t Wed Jan 30 15:35:00 2013 -0800
+++ b/tests/test-rebase-bookmarks.t Wed Jan 30 16:08:32 2013 -0800
@@ -56,17 +56,35 @@
$ cd a1
$ hg up -q Z
+Test deleting divergent bookmarks from dest (issue3685)
+
+ $ hg book -r 3 Z@diverge
+
+... and also test that bookmarks not on dest or not being moved aren't deleted
+
+ $ hg book -r 3 X@diverge
+ $ hg book -r 0 Y@diverge
+
+ $ hg tglog
+ o 3: 'D' bookmarks: W X@diverge Z@diverge
+ |
+ | @ 2: 'C' bookmarks: Y Z
+ | |
+ | o 1: 'B' bookmarks: X
+ |/
+ o 0: 'A' bookmarks: Y@diverge
+
$ hg rebase -s Y -d 3
saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
$ hg tglog
@ 3: 'C' bookmarks: Y Z
|
- o 2: 'D' bookmarks: W
+ o 2: 'D' bookmarks: W X@diverge
|
| o 1: 'B' bookmarks: X
|/
- o 0: 'A' bookmarks:
+ o 0: 'A' bookmarks: Y@diverge
Keep bookmarks to the correct rebased changeset