Patchwork [03,of,19] commit: factor out post-commit cleanup into workingctx

login
register
mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:29 p.m.
Message ID <ae3daa803078b08571d1.1360538993@dev010.prn1.facebook.com>
Download mbox | patch
Permalink /patch/945/
State Accepted
Commit 4fb92f14a97a69d88f1081cacab0f0ca846417cd
Headers show

Comments

David Schleimer - Feb. 10, 2013, 11:29 p.m.
# HG changeset patch
# User David Schleimer <dschleimer@fb.com>
# Date 1360330568 28800
# Node ID ae3daa803078b08571d1ad602d5d32c92e15475d
# Parent  e13d648bab573f580b7c160c61985bd0cbb66364
commit: factor out post-commit cleanup into workingctx

This pulls some of the logic for the cleanup that needs to happen
after a commit has been made otu of localrepo.commit and into
workingctx.  This is part of a larger refactoring effort that will
eventually allow us to perform some types of merges in-memory.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1138,6 +1138,22 @@ 
             finally:
                 wlock.release()
 
+    def markcommitted(self, node):
+        """Perform post-commit cleanup necessary after commiting this workingctx
+
+        Specifically, this updates backing stores this working context
+        wraps to reflect the fact that the changes reflected by this
+        workingctx have been committed.  For example, it marks
+        modified and added files as normal in the dirstate.
+
+        """
+
+        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)
+
     def dirs(self):
         return set(self._repo.dirstate.dirs())
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1279,11 +1279,7 @@ 
 
             # update bookmarks, dirstate and mergestate
             bookmarks.update(self, [p1, p2], ret)
-            for f in changes[0] + changes[1]:
-                self.dirstate.normal(f)
-            for f in changes[2]:
-                self.dirstate.drop(f)
-            self.dirstate.setparents(ret)
+            cctx.markcommitted(ret)
             ms.reset()
         finally:
             wlock.release()