From: W. Trevor King Date: Mon, 27 Jan 2014 18:01:42 +0000 (-0800) Subject: vcs.mercurial: Shell out to hg instead of using the mercurial package X-Git-Tag: v0.6~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2c93d234ed05f42f73bc9e30238d9cb1eb22412a;p=update-copyright.git vcs.mercurial: Shell out to hg instead of using the mercurial package Mercurial doesn't have Python 3 support, and has no plans for adding it in the near future [1]. It's a pretty painless conversion to shell out instead (as we already do for Git), so go that route instead. [1]: http://mercurial.selenic.com/wiki/SupportedPythonVersions#Python_3.x_support --- diff --git a/update_copyright/vcs/mercurial.py b/update_copyright/vcs/mercurial.py index 6deee3c..09700d2 100644 --- a/update_copyright/vcs/mercurial.py +++ b/update_copyright/vcs/mercurial.py @@ -15,16 +15,6 @@ # You should have received a copy of the GNU General Public License along with # update-copyright. If not, see . -from __future__ import absolute_import - -import io as _io -import os as _os -import sys as _sys - -import mercurial as _mercurial -from mercurial.__version__ import version as _version -import mercurial.dispatch as _mercurial_dispatch - from . import VCSBackend as _VCSBackend from . import utils as _utils @@ -37,22 +27,9 @@ class MercurialBackend (_VCSBackend): self._version = _version def _hg_cmd(*args): - cwd = _os.getcwd() - stdout = _sys.stdout - stderr = _sys.stderr - tmp_stdout = _io.StringIO() - tmp_stderr = _io.StringIO() - _sys.stdout = tmp_stdout - _sys.stderr = tmp_stderr - _os.chdir(self._root) - try: - _mercurial_dispatch.dispatch(list(args)) - finally: - _os.chdir(cwd) - _sys.stdout = stdout - _sys.stderr = stderr - return (tmp_stdout.getvalue().rstrip('\n'), - tmp_stderr.getvalue().rstrip('\n')) + status,stdout,stderr = _utils.invoke( + ['hg'] + list(args), cwd=self._root, unicode_output=True) + return stdout.rstrip('\n') def _years(self, filename=None): args = [