Bug 1402010 - Normalize paths according to finder's base; r?chmanchester
e9416a307987f accidentally regressed various `mach file-info` commands
due to the used Finder being rooted at a different directory.
In this commit, we change the path normalization code to always
normalize paths against the relative path to the root of the Finder
being used.
MozReview-Commit-ID: C3S6Zs4qPBR
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -333,16 +333,21 @@ class MozbuildObject(ProcessExecutionMix
If ``vcs_revision`` is not defined and the version control checkout is
sparse, this implies ``vcs_revision='.'``.
If ``vcs_revision`` is ``.`` (denotes the parent of the working
directory), we will verify that the working directory is clean unless
``vcs_check_clean`` is False. This prevents confusion due to uncommitted
file changes not being reflected in the reader.
+
+ The reader returned for non-vcs mode is based at the root of the
+ filesystem whereas the one for VCS mode is rooted at topsrcdir. This
+ is somewhat wonky.
+ TODO improve this behavior.
"""
from mozbuild.frontend.reader import (
default_finder,
BuildReader,
EmptyConfig,
)
from mozpack.files import (
MercurialRevisionFinder,
--- a/python/mozbuild/mozbuild/frontend/mach_commands.py
+++ b/python/mozbuild/mozbuild/frontend/mach_commands.py
@@ -159,30 +159,30 @@ class MozbuildFileCommands(MachCommandBa
print(e.message)
return 1
def _get_files_info(self, paths, rev=None):
reader = self.mozbuild_reader(config_mode='empty', vcs_revision=rev)
# Normalize to relative from topsrcdir.
- relpaths = []
+ query_paths = []
for p in paths:
a = mozpath.abspath(p)
if not mozpath.basedir(a, [self.topsrcdir]):
raise InvalidPathException('path is outside topsrcdir: %s' % p)
- relpaths.append(mozpath.relpath(a, self.topsrcdir))
+ query_paths.append(mozpath.relpath(a, reader.finder.base))
# Expand wildcards.
# One variable is for ordering. The other for membership tests.
# (Membership testing on a list can be slow.)
allpaths = []
all_paths_set = set()
- for p in relpaths:
+ for p in query_paths:
if '*' not in p:
if p not in all_paths_set:
all_paths_set.add(p)
allpaths.append(p)
continue
if rev:
raise InvalidPathException('cannot use wildcard in version control mode')