From: W. Trevor King Date: Thu, 8 Sep 2011 02:54:00 +0000 (-0400) Subject: Adjust Mercurial execution so it works with version 1.9 and earlier. X-Git-Tag: 1.1.0~175^2~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7d207f7c040db85da48ce3930663cfa10aa88864;p=be.git Adjust Mercurial execution so it works with version 1.9 and earlier. This makes the changes for 1.9 brought in by bb645f8e489b9f50cd0aec7237ec9adb721797a8 optional. If the Mercurial version is 1.9 or greater, the new code is used. Otherwise, the old code is used. --- diff --git a/libbe/storage/vcs/hg.py b/libbe/storage/vcs/hg.py index acf391d..b61e796 100644 --- a/libbe/storage/vcs/hg.py +++ b/libbe/storage/vcs/hg.py @@ -83,10 +83,16 @@ class Hg(base.VCS): assert len(kwargs) == 1, kwargs fullargs = ['--cwd', kwargs['cwd']] fullargs.extend(args) - output = StringIO.StringIO() cwd = os.getcwd() - req = mercurial.dispatch.request(fullargs, fout=output) - mercurial.dispatch.dispatch(req) + output = StringIO.StringIO() + if self.version_cmp(1,9): + req = mercurial.dispatch.request(fullargs, fout=output) + mercurial.dispatch.dispatch(req) + else: + stdout = sys.stdout + sys.stdout = output + mercurial.dispatch.dispatch(fullargs) + sys.stdout = stdout os.chdir(cwd) return output.getvalue().rstrip('\n')