Mercurial > hg
changeset 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 | 448486e12c13 |
children | c361db7a5f14 |
files | mercurial/cext/dirs.c mercurial/cext/parsers.c mercurial/hgweb/hgwebdir_mod.py mercurial/match.py mercurial/policy.py mercurial/util.py relnotes/next tests/test-origbackup-conflict.t |
diffstat | 8 files changed, 24 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cext/dirs.c Thu Jul 13 23:43:16 2017 -0700 +++ b/mercurial/cext/dirs.c Tue May 16 11:00:38 2017 -0700 @@ -42,6 +42,9 @@ break; pos -= 1; } + if (pos == -1) { + return 0; + } return pos; }
--- a/mercurial/cext/parsers.c Thu Jul 13 23:43:16 2017 -0700 +++ b/mercurial/cext/parsers.c Tue May 16 11:00:38 2017 -0700 @@ -667,7 +667,7 @@ void manifest_module_init(PyObject *mod); void revlog_module_init(PyObject *mod); -static const int version = 12; +static const int version = 13; static void module_init(PyObject *mod) {
--- a/mercurial/hgweb/hgwebdir_mod.py Thu Jul 13 23:43:16 2017 -0700 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue May 16 11:00:38 2017 -0700 @@ -414,14 +414,10 @@ return self.makeindex(req, res, tmpl, subdir) def _virtualdirs(): - # Check the full virtual path, each parent, and the root ('') - if virtual != '': - yield virtual - - for p in util.finddirs(virtual): - yield p - - yield '' + # Check the full virtual path, and each parent + yield virtual + for p in util.finddirs(virtual): + yield p for virtualrepo in _virtualdirs(): real = repos.get(virtualrepo)
--- 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.
--- a/mercurial/policy.py Thu Jul 13 23:43:16 2017 -0700 +++ b/mercurial/policy.py Tue May 16 11:00:38 2017 -0700 @@ -69,7 +69,7 @@ (r'cext', r'bdiff'): 3, (r'cext', r'mpatch'): 1, (r'cext', r'osutil'): 4, - (r'cext', r'parsers'): 12, + (r'cext', r'parsers'): 13, } # map import request to other package or module
--- a/mercurial/util.py Thu Jul 13 23:43:16 2017 -0700 +++ b/mercurial/util.py Tue May 16 11:00:38 2017 -0700 @@ -3209,6 +3209,7 @@ while pos != -1: yield path[:pos] pos = path.rfind('/', 0, pos) + yield '' # convenient shortcut
--- a/relnotes/next Thu Jul 13 23:43:16 2017 -0700 +++ b/relnotes/next Tue May 16 11:00:38 2017 -0700 @@ -32,3 +32,6 @@ * `match.visitdir()` and `match.visitchildrenset()` now expect the empty string instead of '.' to indicate the root directory. + + * `util.dirs()` and `util.finddirs()` now include an entry for the + root directory (empty string).
--- a/tests/test-origbackup-conflict.t Thu Jul 13 23:43:16 2017 -0700 +++ b/tests/test-origbackup-conflict.t Tue May 16 11:00:38 2017 -0700 @@ -129,8 +129,9 @@ b/c: replacing untracked file getting b/c creating directory: $TESTTMP/repo/.hg/badorigbackups/b - abort: $ENOTDIR$: *$TESTTMP/repo/.hg/badorigbackups/b* (glob) - [255] - $ cat .hg/badorigbackups - data - + removing conflicting file: $TESTTMP/repo/.hg/badorigbackups + getting d + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark c1) + $ ls .hg/badorigbackups/b + c