changeset 46778:62c2857a174b

amend: mark commit obsolete after moving working copy We were doing it this way: 1. move working copy (repo.setparents) 2. add obsmarkers (scmutil.cleanupnodes) 3. fix dirstate (dirstate.normal/drop) Step 1 and 3 are closely related, so let's move them together. It seems safest to create the obsmarkers last. This patch thus makes the order 1, 3, 2. Differential Revision: https://phab.mercurial-scm.org/D10197
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 26 Feb 2019 15:54:20 -0800
parents 685383486d0a
children cb70dabe5718
files mercurial/cmdutil.py
diffstat 1 files changed, 15 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Mar 10 06:03:01 2021 +0100
+++ b/mercurial/cmdutil.py	Tue Feb 26 15:54:20 2019 -0800
@@ -2967,20 +2967,6 @@
 
         # Reroute the working copy parent to the new changeset
         repo.setparents(newid, nullid)
-        mapping = {old.node(): (newid,)}
-        obsmetadata = None
-        if opts.get(b'note'):
-            obsmetadata = {b'note': encoding.fromlocal(opts[b'note'])}
-        backup = ui.configbool(b'rewrite', b'backup-bundle')
-        scmutil.cleanupnodes(
-            repo,
-            mapping,
-            b'amend',
-            metadata=obsmetadata,
-            fixphase=True,
-            targetphase=commitphase,
-            backup=backup,
-        )
 
         # Fixing the dirstate because localrepo.commitctx does not update
         # it. This is rather convenient because we did not need to update
@@ -3003,6 +2989,21 @@
         for f in removedfiles:
             dirstate.drop(f)
 
+        mapping = {old.node(): (newid,)}
+        obsmetadata = None
+        if opts.get(b'note'):
+            obsmetadata = {b'note': encoding.fromlocal(opts[b'note'])}
+        backup = ui.configbool(b'rewrite', b'backup-bundle')
+        scmutil.cleanupnodes(
+            repo,
+            mapping,
+            b'amend',
+            metadata=obsmetadata,
+            fixphase=True,
+            targetphase=commitphase,
+            backup=backup,
+        )
+
     return newid