Bug 1402010 - Normalize paths according to finder's base; r?chmanchester draft
authorGregory Szorc <gps@mozilla.com>
Thu, 21 Sep 2017 11:29:05 -0700
changeset 668485 a71490730baa86f21a310b47fd975b6d36003cae
parent 668484 83afa692da84387ded48b42f36f05911a4cbadb0
child 668486 51607c9defa7b2bcb537f9f7c6d9158f1357ef9f
push id81062
push usergszorc@mozilla.com
push dateThu, 21 Sep 2017 18:37:24 +0000
reviewerschmanchester
bugs1402010
milestone58.0a1
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
python/mozbuild/mozbuild/base.py
python/mozbuild/mozbuild/frontend/mach_commands.py
--- 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')