localrepo: use workingctx for validation in commit
authorDavid Schleimer <dschleimer@fb.com>
Fri, 08 Feb 2013 05:36:08 -0800
changeset 18660 7e6946ed5756
parent 18659 b946470efed9
child 18661 4fb92f14a97a
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.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Feb 08 05:36:07 2013 -0800
+++ b/mercurial/localrepo.py	Fri Feb 08 05:36:08 2013 -0800
@@ -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)