Patchwork [2,of,2] amend: stop updating the bookmarks twice

login
register
mail settings
Submitter Pierre-Yves David
Date July 1, 2015, 6:04 a.m.
Message ID <36b3f896035ee0448824.1435730668@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9845/
State Accepted
Headers show

Comments

Pierre-Yves David - July 1, 2015, 6:04 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1435729168 25200
#      Tue Jun 30 22:39:28 2015 -0700
# Node ID 36b3f896035ee0448824d5b8f74ba7553e25d04a
# Parent  cc88486e842ce1cf3b696606b98505ae52031afc
amend: stop updating the bookmarks twice

There was code to move the bookmarks around both in the 'cmdutil' help and in
the main 'commit' function. We kill the 'commit' version as it is performed
outside the transaction.

The debug note is moved in cmdutil.
Matt Mackall - July 1, 2015, 7:23 p.m.
On Tue, 2015-06-30 at 23:04 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1435729168 25200
> #      Tue Jun 30 22:39:28 2015 -0700
> # Node ID 36b3f896035ee0448824d5b8f74ba7553e25d04a
> # Parent  cc88486e842ce1cf3b696606b98505ae52031afc
> amend: stop updating the bookmarks twice

These are queued for default, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2612,10 +2612,12 @@  def amend(ui, repo, commitfunc, old, ext
                 # Move bookmarks from old parent to amend commit
                 bms = repo.nodebookmarks(old.node())
                 if bms:
                     marks = repo._bookmarks
                     for bm in bms:
+                        ui.debug('moving bookmarks %r from %s to %s\n' %
+                                 (marks, old.hex(), hex(newid)))
                         marks[bm] = newid
                     marks.recordchange(tr)
             #commit the whole amend process
             createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
             if createmarkers and newid != old.node():
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1521,25 +1521,14 @@  def commit(ui, repo, *pats, **opts):
                                opts.get('user') or old.user(),
                                opts.get('date') or old.date(),
                                match,
                                extra=extra)
 
-        active = repo._activebookmark
-        marks = old.bookmarks()
         node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
         if node == old.node():
             ui.status(_("nothing changed\n"))
             return 1
-        elif marks:
-            ui.debug('moving bookmarks %r from %s to %s\n' %
-                     (marks, old.hex(), hex(node)))
-            newmarks = repo._bookmarks
-            for bm in marks:
-                newmarks[bm] = node
-                if bm == active:
-                    bookmarks.activate(repo, bm)
-            newmarks.write()
     else:
         def commitfunc(ui, repo, message, match, opts):
             backup = ui.backupconfig('phases', 'new-commit')
             baseui = repo.baseui
             basebackup = baseui.backupconfig('phases', 'new-commit')