Bug 1377216 - Use substs for determining checkout type; r?glandium
We now have a variable in config.status for recording the checkout
type. These helper functions for determining if we're Mercurial or Git
can now be one-liners.
As a bonus, we no longer do I/O as part of this function.
MozReview-Commit-ID: HT9sbOhDEkf
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -746,34 +746,22 @@ class MachCommandConditions(object):
"""Must have an Android build."""
if hasattr(cls, 'substs'):
return cls.substs.get('MOZ_WIDGET_TOOLKIT') == 'android'
return False
@staticmethod
def is_hg(cls):
"""Must have a mercurial source checkout."""
- if hasattr(cls, 'substs'):
- top_srcdir = cls.substs.get('top_srcdir')
- elif hasattr(cls, 'topsrcdir'):
- top_srcdir = cls.topsrcdir
- else:
- return False
- return top_srcdir and os.path.isdir(os.path.join(top_srcdir, '.hg'))
+ return getattr(cls, 'substs', {}).get('VCS_CHECKOUT_TYPE') == 'hg'
@staticmethod
def is_git(cls):
"""Must have a git source checkout."""
- if hasattr(cls, 'substs'):
- top_srcdir = cls.substs.get('top_srcdir')
- elif hasattr(cls, 'topsrcdir'):
- top_srcdir = cls.topsrcdir
- else:
- return False
- return top_srcdir and os.path.exists(os.path.join(top_srcdir, '.git'))
+ return getattr(cls, 'substs', {}).get('VCS_CHECKOUT_TYPE') == 'git'
class PathArgument(object):
"""Parse a filesystem path argument and transform it in various ways."""
def __init__(self, arg, topsrcdir, topobjdir, cwd=None):
self.arg = arg
self.topsrcdir = topsrcdir