mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1341207 - Use MachCommandConditions.is_{git,hg} for mach clobber python
. r=chmanchester
--HG-- extra : rebase_source : 4b78d3857cca67455343847ab27902c5877e0a6e
This commit is contained in:
parent
3a2a54e7d2
commit
4f2c73ffd9
@ -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):
|
||||
|
@ -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']
|
||||
|
Loading…
Reference in New Issue
Block a user