diff mercurial/repair.py @ 17264:ec7b9bec19c9 stable

strip: move bookmarks to nearest ancestor rather than '.' If you've got this graph: 0-1-2 \ 3 and 3 is checked out, 2 is bookmarked with "broken", and you do "hg strip 2", the bookmark will move to 3, not 1. That's always struck me as a bug. This change makes bookmarks move to the tipmost ancestor of the stripped set rather than the currently-checked-out revision, which is what I always expected should happen.
author Augie Fackler <raf@durin42.com>
date Thu, 26 Jul 2012 16:57:50 -0500
parents c8eda7bbdcab
children 7c865f30e2b8
line wrap: on
line diff
--- a/mercurial/repair.py	Fri Jul 27 12:33:48 2012 -0500
+++ b/mercurial/repair.py	Thu Jul 26 16:57:50 2012 -0500
@@ -111,6 +111,13 @@
         saverevs.difference_update(descendants)
     savebases = [cl.node(r) for r in saverevs]
     stripbases = [cl.node(r) for r in tostrip]
+    rset = ' or '.join([str(r) for r in tostrip])
+    newbmtarget = repo.revs('sort(heads(ancestors(%r) - (%r)), -rev)',
+                            rset, rset)
+    if newbmtarget:
+        newbmtarget = newbmtarget[0]
+    else:
+        newbmtarget = '.'
 
     bm = repo._bookmarks
     updatebm = []
@@ -174,7 +181,7 @@
                     ui.warn(_('error removing %s: %s\n') % (undofile, str(e)))
 
         for m in updatebm:
-            bm[m] = repo['.'].node()
+            bm[m] = repo[newbmtarget].node()
         bookmarks.write(repo)
     except: # re-raises
         if backupfile:
@@ -192,4 +199,3 @@
         # Multiple branches involved in strip. Will allow branchcache to become
         # invalid and later on rebuilt from scratch
         repo.destroyed()
-