[PATCH 1 of 2] amend: move createmarkers evaluation earlier

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jul 1 19:24:53 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1435728520 25200
#      Tue Jun 30 22:28:40 2015 -0700
# Node ID 4a71f50572264b319960b78a4630b8ddef8b929c
# Parent  36b3f896035ee0448824d5b8f74ba7553e25d04a
amend: move createmarkers evaluation earlier

The value is used at multiple points in the function. Retrieving the value in the
middle of the transaction scope gives the false impression that it has a single
user. We move it at the start of the function to clarify this.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2452,10 +2452,11 @@ def amend(ui, repo, commitfunc, old, ext
     if obsolete.isenabled(repo, obsolete.createmarkersopt):
         ui.username() # raise exception if username not set
 
     ui.note(_('amending changeset %s\n') % old)
     base = old.p1()
+    createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
 
     wlock = dsguard = lock = newid = None
     try:
         wlock = repo.wlock()
         dsguard = dirstateguard(repo, 'amend')
@@ -2617,11 +2618,10 @@ def amend(ui, repo, commitfunc, old, ext
                         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():
                 # mark the new changeset as successor of the rewritten one
                 new = repo[newid]
                 obs = [(old, (new,))]
                 if node:


More information about the Mercurial-devel mailing list