Patchwork D8002: pathutil: mark parent directories as audited as we go

login
register
mail settings
Submitter phabricator
Date Jan. 25, 2020, 1:40 a.m.
Message ID <differential-rev-PHID-DREV-n7chb3nznyqcoyk7afks-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44650/
State Superseded
Headers show

Comments

phabricator - Jan. 25, 2020, 1:40 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Before 0b7ce0b16d8a <https://phab.mercurial-scm.org/rHG0b7ce0b16d8a629cee8610c62c16307ccefa5893> (pathauditor: change parts verification order to
  be root first, 2016-02-11), we used to validate child directories
  before parents. It was then important to only mark the child audited
  only after we had audited its parent (ancestors). I'm pretty sure we
  don't need to do that any more, now that we audit parents before
  children.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8002

AFFECTED FILES
  mercurial/pathutil.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py
--- a/mercurial/pathutil.py
+++ b/mercurial/pathutil.py
@@ -99,7 +99,6 @@ 
 
         parts.pop()
         normparts.pop()
-        prefixes = []
         # It's important that we check the path parts starting from the root.
         # This means we won't accidentally traverse a symlink into some other
         # filesystem (which is potentially expensive to access).
@@ -110,13 +109,11 @@ 
                 continue
             if self._realfs:
                 self._checkfs(prefix, path)
-            prefixes.append(normprefix)
+            if self._cached:
+                self.auditeddir.add(normprefix)
 
         if self._cached:
             self.audited.add(normpath)
-            # 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"
-            self.auditeddir.update(prefixes)
 
     def _checkfs(self, prefix, path):
         """raise exception if a file system backed check fails"""