Patchwork [2,of,2] amend: move obsmarkers creation in the "new changeset" conditional

login
register
mail settings
Submitter Pierre-Yves David
Date July 1, 2015, 7:24 p.m.
Message ID <4bb0ed0dc02d2bf7391c.1435778694@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9847/
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 1411891756 25200
#      Sun Sep 28 01:09:16 2014 -0700
# Node ID 4bb0ed0dc02d2bf7391cc6c7422c747b02ba1539
# Parent  4a71f50572264b319960b78a4630b8ddef8b929c
amend: move obsmarkers creation in the "new changeset" conditional

We already check if we created a new changesets right above this piece of code,
so we can just drop the condition and indent the markers creation.
Matt Mackall - July 1, 2015, 10:58 p.m.
On Wed, 2015-07-01 at 12:24 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1411891756 25200
> #      Sun Sep 28 01:09:16 2014 -0700
> # Node ID 4bb0ed0dc02d2bf7391cc6c7422c747b02ba1539
> # Parent  4a71f50572264b319960b78a4630b8ddef8b929c
> amend: move obsmarkers creation in the "new changeset" conditional

Queued for default, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2617,19 +2617,19 @@  def amend(ui, repo, commitfunc, old, ext
                     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
-            if createmarkers and newid != old.node():
-                # mark the new changeset as successor of the rewritten one
-                new = repo[newid]
-                obs = [(old, (new,))]
-                if node:
-                    obs.append((ctx, ()))
-
-                obsolete.createmarkers(repo, obs)
+                #commit the whole amend process
+                if createmarkers:
+                    # mark the new changeset as successor of the rewritten one
+                    new = repo[newid]
+                    obs = [(old, (new,))]
+                    if node:
+                        obs.append((ctx, ()))
+
+                    obsolete.createmarkers(repo, obs)
             tr.close()
         finally:
             tr.release()
         dsguard.close()
         if not createmarkers and newid != old.node():