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

mail settings
Submitter David Schleimer
Date Feb. 10, 2013, 11:29 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/961/
State Accepted
Commit 7e6946ed57565dd01124eedc978f092e9c9c2b83
Headers show


David Schleimer - Feb. 10, 2013, 11:29 p.m.
# HG changeset patch
# User David Schleimer <>
# 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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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)