From 7d207f7c040db85da48ce3930663cfa10aa88864 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 7 Sep 2011 22:54:00 -0400 Subject: [PATCH] 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. --- libbe/storage/vcs/hg.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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') -- 2.26.2