[PATCH 19 of 19] commit: get rid of no-longer needed variable in localrepo.commit

David Schleimer dschleimer at fb.com
Sun Feb 10 17:30:09 CST 2013


# HG changeset patch
# User David Schleimer <dschleimer at fb.com>
# Date 1360536813 28800
# Node ID ec28a1ffc921ff4f156152d9ba0960d912d8ebb2
# Parent  7a150f3cfd3ea54a11dbe5754671d3e82420d40b
commit: get rid of no-longer needed variable in localrepo.commit

Since we moved to modifying a single workingcontext instead of
creating a new one with munged changes, we now have an extra variable
in localrepo.commit.  This diff cleans it up.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1136,44 +1136,43 @@
             merge = len(wctx.parents()) > 1
 
             subs = wctx.preparecommit(match, force)
-            cctx = wctx
 
             if (not force and not extra.get("close") and not merge
-                and not cctx.files()
-                and cctx.branch() == cctx.p1().branch()):
+                and not wctx.files()
+                and wctx.branch() == wctx.p1().branch()):
                 return None
 
-            if merge and cctx.deleted():
+            if merge and wctx.deleted():
                 raise util.Abort(_("cannot commit merge with missing files"))
 
-            if cctx.unresolved():
+            if wctx.unresolved():
                 raise util.Abort(_("unresolved merge conflicts "
                                    "(see hg help resolve)"))
 
-            cctx.setuser(user)
-            cctx.setdate(date)
-            cctx.setextra(extra)
+            wctx.setuser(user)
+            wctx.setdate(date)
+            wctx.setextra(extra)
 
-            cctx.setdescription(text)
+            wctx.setdescription(text)
             if editor:
-                cctx.setdescription(editor(self, cctx, subs))
-            edited = (text != cctx.description())
+                wctx.setdescription(editor(self, wctx, subs))
+            edited = (text != wctx.description())
 
             # commit subs and write new state
             if subs:
-                cctx.commitsubstate()
+                wctx.commitsubstate()
 
             # Save commit message in case this transaction gets rolled back
             # (e.g. by a pretxncommit hook).  Leave the content alone on
             # the assumption that the user will use the same editor again.
-            msgfn = self.savecommitmessage(cctx.description())
+            msgfn = self.savecommitmessage(wctx.description())
 
             p1, p2 = self.dirstate.parents()
             hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
             try:
                 self.hook("precommit", throw=True, parent1=hookp1,
                           parent2=hookp2)
-                ret = self.commitctx(cctx, True)
+                ret = self.commitctx(wctx, True)
             except: # re-raises
                 if edited:
                     self.ui.write(
@@ -1182,7 +1181,7 @@
 
             # update bookmarks, dirstate and mergestate
             bookmarks.update(self, [p1, p2], ret)
-            cctx.markcommitted(ret)
+            wctx.markcommitted(ret)
         finally:
             wlock.release()
 


More information about the Mercurial-devel mailing list