Adjust Mercurial execution so it works with version 1.9 and earlier.
authorW. Trevor King <wking@drexel.edu>
Thu, 8 Sep 2011 02:54:00 +0000 (22:54 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 8 Sep 2011 02:55:40 +0000 (22:55 -0400)
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

index acf391dab45cb07c4b3a53d96b46bcc2ebaccb35..b61e796d118998739d9f77ad40d8799f2c7b378d 100644 (file)
@@ -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')