[PATCH] rebase: reset bookmarks (issue2265 and issue2873)

Matt Mackall mpm at selenic.com
Fri Jul 15 12:20:12 CDT 2011


On Fri, 2011-07-15 at 19:18 +0200, Stefano Tortarolo wrote:
> 2011/7/15 Stefano Tortarolo <stefano.tortarolo at gmail.com>
> 
> > # HG changeset patch
> > # User Stefano Tortarolo <stefano.tortarolo at gmail.com>
> > # Date 1310681425 -7200
> > # Node ID 23019dadbd1bdd89c99162db82f2943c16745543
> > # Parent  487818714d2f280ac575b353a7a21b5ca19a08a8
> > rebase: reset bookmarks (issue2265 and issue2873)
> >
> >
> Please forget this patch... I'll resend another version with minor fixes
> soon.

Alright, here are the cleanups I made:

diff -r ea914376ae26 hgext/rebase.py
--- a/hgext/rebase.py	Fri Jul 15 00:10:25 2011 +0200
+++ b/hgext/rebase.py	Fri Jul 15 12:19:30 2011 -0500
@@ -182,7 +182,7 @@
             targetancestors.add(target)
 
         # Keep track of the current bookmarks in order to reset them later
-        current_bookmarks = repo._bookmarks.copy()
+        currentbookmarks = repo._bookmarks.copy()
 
         sortedstate = sorted(state)
         total = len(sortedstate)
@@ -244,12 +244,6 @@
         if 'qtip' in repo.tags():
             updatemq(repo, state, skipped, **opts)
 
-        # Nodeids are needed to reset bookmarks 
-        nstate = dict([(repo[k].node(), repo[v].node()
-                     if v != nullmerge else nullmerge
-                     ) # This ugly trick is needed to avoid repo[nullmerge]
-                     for k, v in state.iteritems()])
-
         if not keepf:
             # Remove no more useful revisions
             rebased = [rev for rev in state if state[rev] != nullmerge]
@@ -261,7 +255,7 @@
                     # backup the old csets by default
                     repair.strip(ui, repo, repo[min(rebased)].node(), "all")
 
-        updatebookmarks(repo, nstate, current_bookmarks, **opts)
+        updatebookmarks(repo, state, currentbookmarks, **opts)
 
         clearstatus(repo)
         ui.note(_("rebase completed\n"))
@@ -412,11 +406,17 @@
         mq.series_dirty = True
         mq.savedirty()
 
-def updatebookmarks(repo, nstate, original_bookmarks, **opts):
+def updatebookmarks(repo, state, originalbookmarks, **opts):
     'Move bookmarks to their correct changesets'
 
+    # Nodeids are needed to reset bookmarks
+    nstate = {}
+    for k, v in state.iteritems():
+        if v != nullmerge:
+            nstate[repo[k].node()] = repo[v].node()
+
     current = repo._bookmarkcurrent
-    for k, v in original_bookmarks.iteritems():
+    for k, v in originalbookmarks.iteritems():
         if v in nstate:
             if nstate[v] != nullmerge:
                 # reset the pointer if the bookmark was moved incorrectly

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list