diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py index d1ebd9fd4d9a..c33ddeddaf2a 100644 --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -777,16 +777,22 @@ class MachCommandConditions(object): """Must have a mercurial source checkout.""" if hasattr(cls, 'substs'): top_srcdir = cls.substs.get('top_srcdir') - return top_srcdir and os.path.isdir(os.path.join(top_srcdir, '.hg')) - return False + elif hasattr(cls, 'topsrcdir'): + top_srcdir = cls.topsrcdir + else: + return False + return top_srcdir and os.path.isdir(os.path.join(top_srcdir, '.hg')) @staticmethod def is_git(cls): """Must have a git source checkout.""" if hasattr(cls, 'substs'): top_srcdir = cls.substs.get('top_srcdir') - return top_srcdir and os.path.exists(os.path.join(top_srcdir, '.git')) - return False + elif hasattr(cls, 'topsrcdir'): + top_srcdir = cls.topsrcdir + else: + return False + return top_srcdir and os.path.exists(os.path.join(top_srcdir, '.git')) class PathArgument(object): diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index da8eee35f5c1..08711bfd1fa0 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -695,9 +695,9 @@ class Clobber(MachCommandBase): raise if 'python' in what: - if os.path.isdir(mozpath.join(self.topsrcdir, '.hg')): + if conditions.is_hg(self): cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[co]'] - elif os.path.isdir(mozpath.join(self.topsrcdir, '.git')): + elif conditions.is_git(self): cmd = ['git', 'clean', '-f', '-x', '*.py[co]'] else: cmd = ['find', '.', '-type', 'f', '-name', '*.py[co]', '-delete']