commit: hoist the rest of the dirstate manipulation out of commitctx
authorMatt Mackall <mpm@selenic.com>
Thu, 14 May 2009 13:24:39 -0500
changeset 8416 9dfee83c93c8
parent 8415 221a18019b2b
child 8417 39cf453da958
commit: hoist the rest of the dirstate manipulation out of commitctx
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu May 14 13:24:39 2009 -0500
+++ b/mercurial/localrepo.py	Thu May 14 13:24:39 2009 -0500
@@ -814,6 +814,14 @@
                                       extra, changes)
             ret = self.commitctx(wctx, editor, True)
             ms.reset()
+
+            # update dirstate
+            for f in changes[0] + changes[1]:
+                self.dirstate.normal(f)
+            for f in changes[2]:
+                self.dirstate.forget(f)
+            self.dirstate.setparents(ret)
+
             return ret
 
         finally:
@@ -821,7 +829,7 @@
                 self.dirstate.invalidate() # didn't successfully commit
             wlock.release()
 
-    def commitctx(self, ctx, editor=None, working=False):
+    def commitctx(self, ctx, editor=None, error=False):
         """Add a new revision to current repository.
 
         Revision information is passed via the context argument.
@@ -855,11 +863,8 @@
                     new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
                                               changed)
                     m1.set(f, fctx.flags())
-                    if working:
-                        self.dirstate.normal(f)
-
                 except (OSError, IOError):
-                    if working:
+                    if error:
                         self.ui.warn(_("trouble committing %s!\n") % f)
                         raise
                     else:
@@ -906,11 +911,6 @@
             if self.branchcache:
                 self.branchtags()
 
-            if working:
-                self.dirstate.setparents(n)
-                for f in removed:
-                    self.dirstate.forget(f)
-
             self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
             return n
         finally: