Patchwork [01,of,19] localrepo: create context used for actual commit earlier

login
register
mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:29 p.m.
Message ID <07bdd03d86dcce1558d7.1360538991@dev010.prn1.facebook.com>
Download mbox | patch
Permalink /patch/943/
State Accepted
Commit b946470efed9edb076a1df4286173925f65d9f4c
Headers show

Comments

David Schleimer - Feb. 10, 2013, 11:29 p.m.
# HG changeset patch
# User David Schleimer <dschleimer@fb.com>
# Date 1360330567 28800
# Node ID 07bdd03d86dcce1558d793c29c062e05e5cf02da
# Parent  cd01b0fef1b0bae101c66c8acd9ba7c013548390
localrepo: create context used for actual commit earlier

localrepo.commit creates a workingctx, calls self.status, does some
munging on the changes status returns, does some validation on those
changes, and then creates a new workingctx from the changes.  This
moves the creation of the new workginctx ahead of some validation,
with the intention of refactoring some of that validation logic into
the workingctx, so that it can be reused elsewhere.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1230,6 +1230,8 @@ 
                     elif f not in self.dirstate:
                         fail(f, _("file not tracked!"))
 
+            cctx = context.workingctx(self, text, user, date, extra, changes)
+
             if (not force and not extra.get("close") and not merge
                 and not (changes[0] or changes[1] or changes[2])
                 and wctx.branch() == wctx.p1().branch()):
@@ -1244,7 +1246,6 @@ 
                     raise util.Abort(_("unresolved merge conflicts "
                                        "(see hg help resolve)"))
 
-            cctx = context.workingctx(self, text, user, date, extra, changes)
             if editor:
                 cctx._text = editor(self, cctx, subs)
             edited = (text != cctx._text)