Patchwork [2,of,5] pathauditor: add a way to skip file system check

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 3, 2015, 10:01 p.m.
Message ID <5af761d2a50a28adf385.1449180086@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11793/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 3, 2015, 10:01 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1449168019 28800
#      Thu Dec 03 10:40:19 2015 -0800
# Node ID 5af761d2a50a28adf385a842f8bbcf8d6d7e1a4e
# Parent  6b99a8edfcb1ff9faeb91607408a66586e3b7db7
# EXP-Topic symlink.issue4749
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 5af761d2a50a
pathauditor: add a way to skip file system check

We need to be able to skip it when looking at data within the history. Doing them in all cases leads to buggy behavior like issue4749.

Patch

diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py
--- a/mercurial/pathutil.py
+++ b/mercurial/pathutil.py
@@ -21,19 +21,26 @@  class pathauditor(object):
 
     - ends with a directory separator
     - under top-level .hg
     - starts at the root of a windows drive
     - contains ".."
+
+    More check are also done about the file system states:
     - traverses a symlink (e.g. a/symlink_here/b)
     - inside a nested repository (a callback can be used to approve
       some nested repositories, e.g., subrepositories)
+
+    The file system checks are only done when 'realfs' is set to True (the
+    default). They should be disable then we are auditing path for operation on
+    stored history.
     '''
 
-    def __init__(self, root, callback=None):
+    def __init__(self, root, callback=None, realfs=True):
         self.audited = set()
         self.auditeddir = set()
         self.root = root
+        self._realfs = realfs
         self.callback = callback
         if os.path.lexists(root) and not util.checkcase(root):
             self.normcase = util.normcase
         else:
             self.normcase = lambda x: x
@@ -79,11 +86,12 @@  class pathauditor(object):
         while parts:
             prefix = os.sep.join(parts)
             normprefix = os.sep.join(normparts)
             if normprefix in self.auditeddir:
                 break
-            self._checkfs(prefix, path)
+            if self._realfs:
+                self._checkfs(prefix, path)
             prefixes.append(normprefix)
             parts.pop()
             normparts.pop()
 
         self.audited.add(normpath)