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

--HG--
extra : rebase_source : 8b53b5f50d14c0bdd4ef3dc7b190314af80a76f0
This commit is contained in:
Gregory Szorc 2017-07-14 17:22:14 -07:00
Родитель c310ba24a6
Коммит d32f8a188a
1 изменённых файлов: 2 добавлений и 14 удалений

Просмотреть файл

@ -751,24 +751,12 @@ class MachCommandConditions(object):
@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):