diff mercurial/match.py @ 42343:d8e55c0c642c

util: make util.dirs() and util.finddirs() include root directory (API) This changes the behavior of test-origbackup-conflict.t so it no longer errors out when the backup path points to an existing file. Instead, it replaces the file by a directory. That seems reasonable to me. Differential Revision: https://phab.mercurial-scm.org/D6403
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 16 May 2017 11:00:38 -0700
parents 27d6956d386b
children 38d85ec06552
line wrap: on
line diff
--- a/mercurial/match.py	Thu Jul 13 23:43:16 2017 -0700
+++ b/mercurial/match.py	Tue May 16 11:00:38 2017 -0700
@@ -539,8 +539,7 @@
         dir = normalizerootdir(dir, 'visitdir')
         if self._prefix and dir in self._fileset:
             return 'all'
-        return ('' in self._fileset or
-                dir in self._fileset or
+        return (dir in self._fileset or
                 dir in self._dirs or
                 any(parentdir in self._fileset
                     for parentdir in util.finddirs(dir)))
@@ -621,8 +620,7 @@
         dir = normalizerootdir(dir, 'visitdir')
         if self._prefix and dir in self._roots:
             return 'all'
-        return ('' in self._roots or
-                dir in self._roots or
+        return (dir in self._roots or
                 dir in self._dirs or
                 dir in self._parents or
                 any(parentdir in self._roots
@@ -1386,14 +1384,14 @@
     >>> _rootsdirsandparents(
     ...     [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
     ...      (b'glob', b'g*', b'')])
-    (['g/h', 'g/h', ''], [], ['g', ''])
+    (['g/h', 'g/h', ''], [], ['', 'g'])
     >>> _rootsdirsandparents(
     ...     [(b'rootfilesin', b'g/h', b''), (b'rootfilesin', b'', b'')])
-    ([], ['g/h', ''], ['g', ''])
+    ([], ['g/h', ''], ['', 'g'])
     >>> _rootsdirsandparents(
     ...     [(b'relpath', b'r', b''), (b'path', b'p/p', b''),
     ...      (b'path', b'', b'')])
-    (['r', 'p/p', ''], [], ['p', ''])
+    (['r', 'p/p', ''], [], ['', 'p'])
     >>> _rootsdirsandparents(
     ...     [(b'relglob', b'rg*', b''), (b're', b're/', b''),
     ...      (b'relre', b'rr', b'')])
@@ -1406,8 +1404,6 @@
     # scanned to get to either the roots or the other exact directories.
     p.extend(util.dirs(d))
     p.extend(util.dirs(r))
-    # util.dirs() does not include the root directory, so add it manually
-    p.append('')
 
     # FIXME: all uses of this function convert these to sets, do so before
     # returning.