Patchwork [1,of,2] amend: move createmarkers evaluation earlier

login
register
mail settings
Submitter Pierre-Yves David
Date July 1, 2015, 7:24 p.m.
Message ID <4a71f50572264b319960.1435778693@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9846/
State Accepted
Headers show

Comments

Pierre-Yves David - July 1, 2015, 7:24 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.

Patch

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: