commitctx: replace two dirstate vars with working
authorMatt Mackall <mpm@selenic.com>
Thu, 14 May 2009 13:20:40 -0500
changeset 8399 1c3d5c54cf1c
parent 8398 a45eb410e0f2
child 8400 9eecc471aca3
commitctx: replace two dirstate vars with working
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu May 14 13:20:40 2009 -0500
+++ b/mercurial/localrepo.py	Thu May 14 13:20:40 2009 -0500
@@ -816,8 +816,7 @@
                                                     "(see hg resolve)"))
             wctx = context.workingctx(self, (p1, p2), text, user, date,
                                       extra, changes)
-            r = self._commitctx(wctx, force, force_editor, empty_ok,
-                                True, True)
+            r = self._commitctx(wctx, force, force_editor, empty_ok, True)
             ms.reset()
             return r
 
@@ -833,13 +832,12 @@
         lock = self.lock()
         try:
             return self._commitctx(ctx, force=True, force_editor=False,
-                                   empty_ok=True, use_dirstate=False,
-                                   update_dirstate=False)
+                                   empty_ok=True, working=False)
         finally:
             lock.release()
 
     def _commitctx(self, wctx, force=False, force_editor=False, empty_ok=False,
-                  use_dirstate=True, update_dirstate=True):
+                   working=True):
         tr = None
         valid = 0 # don't save the dirstate if this isn't set
         try:
@@ -856,7 +854,7 @@
             m1 = self.manifest.read(c1[0]).copy()
             m2 = self.manifest.read(c2[0])
 
-            if use_dirstate:
+            if working:
                 oldname = c1[5].get("branch") # stored in UTF-8
                 if (not commit and not remove and not force and p2 == nullid
                     and branchname == oldname):
@@ -890,11 +888,11 @@
                         if m1.flags(f) != newflags:
                             changed.append(f)
                     m1.set(f, newflags)
-                    if use_dirstate:
+                    if working:
                         self.dirstate.normal(f)
 
                 except (OSError, IOError):
-                    if use_dirstate:
+                    if working:
                         self.ui.warn(_("trouble committing %s!\n") % f)
                         raise
                     else:
@@ -950,7 +948,7 @@
             lines = [line.rstrip() for line in text.rstrip().splitlines()]
             while lines and not lines[0]:
                 del lines[0]
-            if not lines and use_dirstate:
+            if not lines and working:
                 raise util.Abort(_("empty commit message"))
             text = '\n'.join(lines)
 
@@ -966,11 +964,10 @@
             if self.branchcache:
                 self.branchtags()
 
-            if use_dirstate or update_dirstate:
+            if working:
                 self.dirstate.setparents(n)
-                if use_dirstate:
-                    for f in removed:
-                        self.dirstate.forget(f)
+                for f in removed:
+                    self.dirstate.forget(f)
             valid = 1 # our dirstate updates are complete
 
             self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)