localrepo.commit: use explicit variables, avoid creating new contexts
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Wed, 21 Apr 2010 01:34:12 +0200
changeset 10970 3213e8947975
parent 10969 ca052b484e56
child 10971 cbe400a8e217
localrepo.commit: use explicit variables, avoid creating new contexts
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Wed Apr 21 01:18:31 2010 +0200
+++ b/mercurial/localrepo.py	Wed Apr 21 01:34:12 2010 +0200
@@ -798,10 +798,10 @@
 
         wlock = self.wlock()
         try:
-            p1, p2 = self.dirstate.parents()
             wctx = self[None]
+            merge = len(wctx.parents()) > 1
 
-            if (not force and p2 != nullid and match and
+            if (not force and merge and match and
                 (match.files() or match.anypats())):
                 raise util.Abort(_('cannot partially commit a merge '
                                    '(do not specify files or patterns)'))
@@ -841,9 +841,9 @@
                     elif f not in self.dirstate:
                         fail(f, _("file not tracked!"))
 
-            if (not force and not extra.get("close") and p2 == nullid
+            if (not force and not extra.get("close") and not merge
                 and not (changes[0] or changes[1] or changes[2])
-                and self[None].branch() == self['.'].branch()):
+                and wctx.branch() == wctx.p1().branch()):
                 return None
 
             ms = mergemod.mergestate(self)
@@ -873,8 +873,9 @@
             msgfile.write(cctx._text)
             msgfile.close()
 
+            p1, p2 = self.dirstate.parents()
+            hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
             try:
-                hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
                 self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2)
                 ret = self.commitctx(cctx, True)
             except: