changeset 194:22767a1e61ac

client: make it robust for weird repository path
author Yuya Nishihara <yuya@tcha.org>
date Sat, 11 Nov 2017 20:35:55 +0900
parents 32e8d51ec16c
children 7c37f08d303d
files hglib/client.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hglib/client.py	Sat Nov 11 19:52:48 2017 +0900
+++ b/hglib/client.py	Sat Nov 11 20:35:55 2017 +0900
@@ -46,8 +46,16 @@
         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'}