Check if purge extension is enabled before attempting to enable it in .hg/hgrc

This commit is contained in:
أحمد المحمودي (Ahmed El-Mahmoudy) 2014-01-15 16:08:55 +02:00
parent 6435551e66
commit 65500b367e

View file

@ -472,12 +472,18 @@ class vcs_hg(vcs):
if subprocess.call(['hg', 'update', '-C', rev], if subprocess.call(['hg', 'update', '-C', rev],
cwd=self.local) != 0: cwd=self.local) != 0:
raise VCSException("Hg checkout failed") raise VCSException("Hg checkout failed")
#Also delete untracked files, we have to enable purge extension for that: p = subprocess.Popen(['hg', 'purge', '--all'], stdout=subprocess.PIPE,
with open(self.local+"/.hg/hgrc", "a") as myfile: cwd=self.local)
myfile.write("\n[extensions]\nhgext.purge=") result = p.communicate()[0]
if subprocess.call(['hg', 'purge', '--all'], if "'purge' is provided by the following extension" in result:
cwd=self.local) != 0: #Also delete untracked files, we have to enable purge extension for that:
raise VCSException("HG purge failed") with open(self.local+"/.hg/hgrc", "a") as myfile:
myfile.write("\n[extensions]\nhgext.purge=")
if subprocess.call(['hg', 'purge', '--all'],
cwd=self.local) != 0:
raise VCSException("HG purge failed")
else:
raise VCSException("HG purge failed")
def gettags(self): def gettags(self):
p = subprocess.Popen(['hg', 'tags', '-q'], p = subprocess.Popen(['hg', 'tags', '-q'],