[PATCH 02 of 19] localrepo: use workingctx for validation in commit

David Schleimer dschleimer at fb.com
Sun Feb 10 17:29:52 CST 2013

# HG changeset patch
# User David Schleimer <dschleimer at fb.com>
# Date 1360330568 28800
# Node ID e13d648bab573f580b7c160c61985bd0cbb66364
# Parent  07bdd03d86dcce1558d793c29c062e05e5cf02da
localrepo: use workingctx for validation in commit

This changes localrepo.commit to use the workingctx it creates form
the munged output of localrepo.status while running some precommit
validation.  Specifically, it uses functions that were already present
on the workingctx.  I believe this is a net readabilty improvement,
and that this makes these lines consistent with the refactoring in a
subsequent patch that pulls some of the validation logic into
workingctx so that it can be reused elsewhere.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1233,11 +1233,11 @@
             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 not cctx.files()
                 and wctx.branch() == wctx.p1().branch()):
                 return None
-            if merge and changes[3]:
+            if merge and cctx.deleted():
                 raise util.Abort(_("cannot commit merge with missing files"))
             ms = mergemod.mergestate(self)

More information about the Mercurial-devel mailing list