Bug 1377216 - Use substs for determining checkout type; r?glandium draft
authorGregory Szorc <gps@mozilla.com>
Fri, 14 Jul 2017 17:22:14 -0700
changeset 610966 f8f2b26d11f0c6f5058620adc8b3f2633a8448fd
parent 610965 e50d6f4d3a8123bc62fbcdcb9252d4a1d1d36d0e
child 610967 8807cfeb4b965e96b17c8e0cff6891c8128df83d
push id69070
push userbmo:gps@mozilla.com
push dateWed, 19 Jul 2017 01:11:03 +0000
reviewersglandium
bugs1377216
milestone56.0a1
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
python/mozbuild/mozbuild/base.py
--- 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