mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 20:01:50 +00:00
Bug 1761849 - Removed 'ancestors' function and replaced the only use of it with a Pathlib equivalent r=firefox-build-system-reviewers,mhentges
While testing the change, I noticed that the old implementation also considered the 'current' path as a part of all ancestors. As such, I added an additional path component to the path that is immediately discarded so that the behavior is consistent. Differential Revision: https://phabricator.services.mozilla.com/D142273
This commit is contained in:
parent
271657755e
commit
c69126de73
@ -50,16 +50,6 @@ except Exception:
|
||||
psutil = None
|
||||
|
||||
|
||||
def ancestors(path):
|
||||
"""Emit the parent directories of a path."""
|
||||
while path:
|
||||
yield path
|
||||
newpath = os.path.dirname(path)
|
||||
if newpath == path:
|
||||
break
|
||||
path = newpath
|
||||
|
||||
|
||||
class BadEnvironmentException(Exception):
|
||||
"""Base class for errors raised when the build environment is not sane."""
|
||||
|
||||
@ -169,7 +159,7 @@ class MozbuildObject(ProcessExecutionMixin):
|
||||
mozconfig = info.get("mozconfig")
|
||||
return topsrcdir, topobjdir, mozconfig
|
||||
|
||||
for dir_path in ancestors(cwd):
|
||||
for dir_path in [str(path) for path in [cwd] + list(Path(cwd).parents)]:
|
||||
# If we find a mozinfo.json, we are in the objdir.
|
||||
mozinfo_path = os.path.join(dir_path, "mozinfo.json")
|
||||
if os.path.isfile(mozinfo_path):
|
||||
|
Loading…
x
Reference in New Issue
Block a user