Patchwork [3,of,3,stable] rebase: delete divergent bookmarks on destination (issue3685)

login
register
mail settings
Submitter Siddharth Agarwal
Date Jan. 31, 2013, 2:05 a.m.
Message ID <084b546f5dfa2a651486.1359597959@sid0x220>
Download mbox | patch
Permalink /patch/771/
State Superseded, archived
Headers show

Comments

Siddharth Agarwal - Jan. 31, 2013, 2:05 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1359590912 28800
# Branch stable
# Node ID 084b546f5dfa2a65148621b0b755218f6c163710
# Parent  e651b86d041ea96809fad36ee5ba886087ad2f75
rebase: delete divergent bookmarks on destination (issue3685)

Similar to merge, divergent bookmarks are only deleted when the bookmark is on
the destination parent.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -316,7 +316,7 @@  def rebase(ui, repo, **opts):
             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 @@  def updatemq(repo, state, skipped, **opt
         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()
 
diff --git a/tests/test-rebase-bookmarks.t b/tests/test-rebase-bookmarks.t
--- a/tests/test-rebase-bookmarks.t
+++ b/tests/test-rebase-bookmarks.t
@@ -56,17 +56,35 @@  Move only rebased bookmarks
   $ 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