[PATCH] util: move checkosfilename call from path_auditor to opener

Adrian Buehlmann adrian at cadifra.com
Sun Apr 10 13:00:31 CDT 2011


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1302456709 -7200
# Node ID 61ba09d8d118e4f59666332c4abb937d66c76af4
# Parent  c315ffc13a25c2795067201d9b3f65c8ff6ed079
util: move checkosfilename call from path_auditor to opener

path_auditor is used for checking patterns too, but a pattern is not a valid
filename.

This patch fixes 98ee3dd5bab4, which introduced the bug:

  $ hg log -l3 glob:**.py
  abort: filename contains '*', which is reserved on Windows: mercurial\**.py

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -602,9 +602,6 @@
             prefixes.append(prefix)
             parts.pop()
 
-        r = checkosfilename(path)
-        if r:
-            raise Abort("%s: %s" % (r, path))
         self.audited.add(path)
         # only add prefixes to the cache after checking everything: we don't
         # want to add "foo/bar/baz" before checking if there's a "foo/.hg"
@@ -916,6 +913,9 @@
         os.chmod(name, self.createmode & 0666)
 
     def __call__(self, path, mode="r", text=False, atomictemp=False):
+        r = checkosfilename(path)
+        if r:
+            raise Abort("%s: %s" % (r, path))
         self.auditor(path)
         f = os.path.join(self.base, path)
 


More information about the Mercurial-devel mailing list