Patchwork [3,of,3,hglib] client: make it robust for weird repository path

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 11, 2017, 11:41 a.m.
Message ID <56b442f108be3ef960a6.1510400492@mimosa>
Download mbox | patch
Permalink /patch/25478/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 11, 2017, 11:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1510400155 -32400
#      Sat Nov 11 20:35:55 2017 +0900
# Node ID 56b442f108be3ef960a60805e10ccda003e96bfb
# Parent  cd73c3ee469e22216fbb9116701eed7059c1833c
client: make it robust for weird repository path
Augie Fackler - Nov. 20, 2017, 10:11 p.m.
On Sat, Nov 11, 2017 at 08:41:32PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1510400155 -32400
> #      Sat Nov 11 20:35:55 2017 +0900
> # Node ID 56b442f108be3ef960a60805e10ccda003e96bfb
> # Parent  cd73c3ee469e22216fbb9116701eed7059c1833c
> client: make it robust for weird repository path

queued for hglib, thanks

Patch

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=<value>" form for hg 1.9 compatibility
             for config in configs:
                 self._args += ['--config', config]
         self._env = {'HGPLAIN': '1'}