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

login
register
mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:30 p.m.
Message ID <ec28a1ffc921ff4f1561.1360539009@dev010.prn1.facebook.com>
Download mbox | patch
Permalink /patch/959/
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 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.
Bryan O'Sullivan - Feb. 11, 2013, 9:06 p.m.
On Sun, Feb 10, 2013 at 3:30 PM, David Schleimer <dschleimer@fb.com> wrote:

> commit: get rid of no-longer needed variable in localrepo.commit
>

Nice.

There are a couple of typos in the descriptions of 16 and 17. With the
basically trivial comments aside, the whole series looks good, and marks a
considerable improvement over the code we currently have.

Patch

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()