From 65500b367edc7b1e1139ff67784110b76c0ff539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=A3=D8=AD=D9=85=D8=AF=20=D8=A7=D9=84=D9=85=D8=AD=D9=85?= =?UTF-8?q?=D9=88=D8=AF=D9=8A=20=28Ahmed=20El-Mahmoudy=29?= Date: Wed, 15 Jan 2014 16:08:55 +0200 Subject: [PATCH] Check if purge extension is enabled before attempting to enable it in .hg/hgrc --- fdroidserver/common.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 51be2ae1..45e25c45 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -472,12 +472,18 @@ class vcs_hg(vcs): if subprocess.call(['hg', 'update', '-C', rev], cwd=self.local) != 0: raise VCSException("Hg checkout failed") - #Also delete untracked files, we have to enable purge extension for that: - 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") + p = subprocess.Popen(['hg', 'purge', '--all'], stdout=subprocess.PIPE, + cwd=self.local) + result = p.communicate()[0] + if "'purge' is provided by the following extension" in result: + #Also delete untracked files, we have to enable purge extension for that: + 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): p = subprocess.Popen(['hg', 'tags', '-q'],