This is an archive of the discontinued Mercurial Phabricator instance.

match: make exactmatcher.visitchildrenset return file children as well
ClosedPublic

Authored by spectral on Aug 24 2018, 1:19 AM.

Details

Summary

Previously, if we had an exactmatcher like ['foo.txt', 'a/bar.txt', 'a/b/c/baz.txt'], we'd
get back the following data:

'.': {'a'}
'a': {'b'}
'a/b': {'c'}
'a/b/c': 'this'
'a/b/c/d': set()

This was incorrect, since visitchildrenset explicitly says not to pay attention
to 'foo.txt' and 'a/bar.txt' by not returning them or 'this'. Given the near
impossibility of making visitchildrenset reliabbly produce only subdirectories,
a previous commit has made it documented and expected that visitchildrenset can
return a set containing both files and subdirectories to visit, instead of
implying/requiring that visitchildrenset() return 'this' if there are files to
visit. This makes the code for exactmatcher match this clarified documentation.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

spectral created this revision.Aug 24 2018, 1:19 AM
This revision was automatically updated to reflect the committed changes.
yuja added a subscriber: yuja.Aug 25 2018, 12:35 AM

+ if not self._fileset or dir not in self._dirs:

Just curious why you've added not self._fileset.

Except a vast style change, the important part is just this:

@@ -590,7 +590,7 @@
         if dir not in self._dirs:
             return set()
 
-        candidates = self._dirs - {'.'}
+        candidates = self._fileset | self._dirs - {'.'}
         if dir != '.':
             d = dir + '/'
             candidates = set(c[len(d):] for c in candidates if