From patchwork Sat Nov 11 11:41:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,3,hglib] client: make it robust for weird repository path From: Yuya Nishihara X-Patchwork-Id: 25478 Message-Id: <56b442f108be3ef960a6.1510400492@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sat, 11 Nov 2017 20:41:32 +0900 # HG changeset patch # User Yuya Nishihara # Date 1510400155 -32400 # Sat Nov 11 20:35:55 2017 +0900 # Node ID 56b442f108be3ef960a60805e10ccda003e96bfb # Parent cd73c3ee469e22216fbb9116701eed7059c1833c client: make it robust for weird repository path diff --git a/hglib/client.py b/hglib/client.py --- a/hglib/client.py +++ b/hglib/client.py @@ -46,8 +46,16 @@ class hgclient(object): self._args = [hglib.HGPATH, 'serve', '--cmdserver', 'pipe', '--config', 'ui.interactive=True'] if path: - self._args += ['-R', path] + # perhaps path shouldn't be a unicode string, but accepted for + # backward compatibility. + if isinstance(path, str): + # py2: bytes + bytes, py3: unicode + unicode + self._args += ['-R' + path] + else: + # py2: (ascii) bytes + unicode, py3: bytes + bytes + self._args += [b('-R') + path] if configs: + # don't use "--config=" form for hg 1.9 compatibility for config in configs: self._args += ['--config', config] self._env = {'HGPLAIN': '1'}