changeset 42295:fdd4d668ceb5

context: move contents of committablectx.markcommitted() to workingctx Same reasoning as previous commits: this function updates the dirstate. By not updating the dirstate here, we also fix the close-head test. Differential Revision: https://phab.mercurial-scm.org/D6365
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 10 May 2019 21:55:59 -0700
parents c51b103220c7
children df2f22befdc8
files mercurial/context.py tests/fakedirstatewritetime.py tests/test-close-head.t
diffstat 3 files changed, 13 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Fri May 10 22:18:11 2019 -0700
+++ b/mercurial/context.py	Fri May 10 21:55:59 2019 -0700
@@ -1226,18 +1226,6 @@
 
         """
 
-        with self._repo.dirstate.parentchange():
-            for f in self.modified() + self.added():
-                self._repo.dirstate.normal(f)
-            for f in self.removed():
-                self._repo.dirstate.drop(f)
-            self._repo.dirstate.setparents(node)
-
-        # write changes out explicitly, because nesting wlock at
-        # runtime may prevent 'wlock.release()' in 'repo.commit()'
-        # from immediately doing so for subsequent changing files
-        self._repo.dirstate.write(self._repo.currenttransaction())
-
     def dirty(self, missing=False, merge=True, branch=True):
         return False
 
@@ -1657,7 +1645,17 @@
         return sorted(f for f in ds.matches(match) if ds[f] != 'r')
 
     def markcommitted(self, node):
-        super(workingctx, self).markcommitted(node)
+        with self._repo.dirstate.parentchange():
+            for f in self.modified() + self.added():
+                self._repo.dirstate.normal(f)
+            for f in self.removed():
+                self._repo.dirstate.drop(f)
+            self._repo.dirstate.setparents(node)
+
+        # write changes out explicitly, because nesting wlock at
+        # runtime may prevent 'wlock.release()' in 'repo.commit()'
+        # from immediately doing so for subsequent changing files
+        self._repo.dirstate.write(self._repo.currenttransaction())
 
         sparse.aftercommit(self._repo, node)
 
--- a/tests/fakedirstatewritetime.py	Fri May 10 22:18:11 2019 -0700
+++ b/tests/fakedirstatewritetime.py	Fri May 10 21:55:59 2019 -0700
@@ -74,5 +74,5 @@
 def extsetup(ui):
     extensions.wrapfunction(context.workingctx, '_poststatusfixup',
                             _poststatusfixup)
-    extensions.wrapfunction(context.committablectx, 'markcommitted',
+    extensions.wrapfunction(context.workingctx, 'markcommitted',
                             markcommitted)
--- a/tests/test-close-head.t	Fri May 10 22:18:11 2019 -0700
+++ b/tests/test-close-head.t	Fri May 10 21:55:59 2019 -0700
@@ -37,7 +37,7 @@
   000000000000
   $ hg --config extensions.closehead= close-head -m 'Close old heads' -r 1 2
   $ hg id
-  340d36cac2f4 tip
+  000000000000
   $ hg bookmark
      @                         1:66f7d451a68b
   $ hg heads