Patchwork [10,of,19] commit: pull substate writing into workingctx

login
register
mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:30 p.m.
Message ID <b26b1130ee3a34fe74a6.1360539000@dev010.prn1.facebook.com>
Download mbox | patch
Permalink /patch/950/
State Changes Requested
Headers show

Comments

David Schleimer - Feb. 10, 2013, 11:30 p.m.
# HG changeset patch
# User David Schleimer <dschleimer@fb.com>
# Date 1360330572 28800
# Node ID b26b1130ee3a34fe74a6302a3b08bbfd446c975b
# Parent  84e89fe78426b02aeb09add9a63a04e1e7459ec0
commit: pull substate writing into workingctx

This pulls the logic for committing dirty subrepos and writing out the
substate during localrepo.commit() into the workging context.

This is part of a larger refactoring effort to unify working-copy
commits and in-memory commits.  Among other things, this will allow
for optimizations in graft, rebase, and similar commands.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1199,6 +1199,15 @@ 
 
         return subs, commitsubs, newstate
 
+    def commitsubstate(self, commitsubs, newstate):
+        for s in sorted(commitsubs):
+            sub = self.sub(s)
+            self._repo.ui.status(_('committing subrepository %s\n') %
+                                 subrepo.subrelpath(sub))
+            sr = sub.commit(self.description(), self._user, self._date)
+            newstate[s] = (newstate[s][0], sr)
+        subrepo.writestate(self._repo, newstate)
+
 
     def markcommitted(self, node):
         """Perform post-commit cleanup necessary after commiting this workingctx
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1167,7 +1167,6 @@ 
 
                 subs, commitsubs, newstate = wctx.commitablesubstate(match,
                                                                      force)
-
                 if subs:
                     if (not match('.hgsub') and
                         '.hgsub' in (wctx.modified() + wctx.added())):
@@ -1221,13 +1220,7 @@ 
 
             # commit subs and write new state
             if subs:
-                for s in sorted(commitsubs):
-                    sub = wctx.sub(s)
-                    self.ui.status(_('committing subrepository %s\n') %
-                        subrepo.subrelpath(sub))
-                    sr = sub.commit(cctx.description(), user, date)
-                    newstate[s] = (newstate[s][0], sr)
-                subrepo.writestate(self, newstate)
+                cctx.commitsubstate(commitsubs, newstate)
 
             # Save commit message in case this transaction gets rolled back
             # (e.g. by a pretxncommit hook).  Leave the content alone on