commit: some tidying
authorMatt Mackall <mpm@selenic.com>
Mon, 18 May 2009 17:36:24 -0500
changeset 8501 ab0e3f7ea315
parent 8500 1024bef53d9e
child 8502 51b7d2a68e03
commit: some tidying - simplify handling of 'close' - kill silly wlock=None - sort/uniq files later
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon May 18 17:36:24 2009 -0500
+++ b/mercurial/localrepo.py	Mon May 18 17:36:24 2009 -0500
@@ -769,25 +769,19 @@
 
     def commit(self, files=None, text="", user=None, date=None, match=None,
                force=False, editor=False, extra={}):
-        wlock = None
-        if extra.get("close"):
-            force = True
-        if files:
-            files = list(set(files))
-
         ret = None
         wlock = self.wlock()
         try:
             p1, p2 = self.dirstate.parents()
 
-            if (not force and p2 != nullid and
-                (match and (match.files() or match.anypats()))):
+            if (not force and p2 != nullid and match and
+                (match.files() or match.anypats())):
                 raise util.Abort(_('cannot partially commit a merge '
                                    '(do not specify files or patterns)'))
 
             if files:
                 modified, removed = [], []
-                for f in files:
+                for f in sorted(set(files)):
                     s = self.dirstate[f]
                     if s in 'nma':
                         modified.append(f)
@@ -799,9 +793,9 @@
             else:
                 changes = self.status(match=match)
 
-            if (not (changes[0] or changes[1] or changes[2])
-                and not force and p2 == nullid and
-                self[None].branch() == self['.'].branch()):
+            if (not force and not extra.get("close") and p2 == nullid
+                and not (changes[0] or changes[1] or changes[2])
+                and self[None].branch() == self['.'].branch()):
                 self.ui.status(_("nothing changed\n"))
                 return None