08617b414906 — Alain Leufroy 1 year, 24 days ago
compat: mercurial 5.3 executed with python 3
3 files changed, 18 insertions(+), 27 deletions(-)

M lairucrem/extension.py
M lairucrem/process.py
M lairucrem/utils.py
M lairucrem/extension.py +15 -24
@@ 12,10 12,10 @@ side.
 import itertools
 import re
 
-from mercurial import cmdutil, graphmod, i18n, scmutil, templatekw
+from mercurial import graphmod, i18n, scmutil, templatekw
 from mercurial.__version__ import version as hgversion
 
-hgversion = tuple(int(v) for v in re.split(r'\D', hgversion) if v)
+hgversion = tuple(int(v) for v in re.split(br'\D', hgversion) if v)
 
 try:
     from mercurial.registrar import command as register_command

          
@@ 54,6 54,7 @@ except ImportError:
 
 testedwith = '4.0 4.1 4.2 4.3 4.4. 4.5 5.1'
 
+
 def monkeypatch(cls, methodname=None):
     """patch a class with decorated method"""
     def decorator(func):

          
@@ 71,34 72,21 @@ if colorext:
     def showlabel(self, msg, label):
         ""
         if label and msg:
-            if msg[-1] == '\n':
-                msg = "\x01%s\x02%s\x03\n" % (label, msg[:-1])
+            if msg[-1] in (b'\n', ord(b'\n')):
+                msg = b"\x01" + label + b"\x02" + msg[:-1] + b"\x03\n"
             else:
-                msg = "\x01%s\x02%s\x03" % (label, msg)
+                msg = b"\x01" + label + b"\x02" + msg + b"\x03"
         return msg
 
 else:
     @monkeypatch(color)
     def colorlabel(ui, msg, label):
         """add color control code according to the mode"""
-        if ui._colormode == 'debug':
-            if label and msg:
-                if msg[-1] == '\n':
-                    msg = "\x01%s\x02%s\x03\n" % (label, msg[:-1])
-                else:
-                    msg = "\x01%s\x02%s\x03" % (label, msg)
-        elif ui._colormode is not None:
-            effects = []
-            for l in label.split():
-                s = ui._styles.get(l, '')
-                if s:
-                    effects.append(s)
-                elif valideffect(ui, l):
-                    effects.append(l)
-            effects = ' '.join(effects)
-            if effects:
-                msg = '\n'.join([_render_effects(ui, line, effects)
-                                 for line in msg.split('\n')])
+        if label and msg:
+            if msg[-1] in (b'\n', ord(b'\n')):
+                msg = b"\x01" + label + b"\x02" + msg[:-1] + b"\x03\n"
+            else:
+                msg = b"\x01" + label + b"\x02" + msg + b"\x03"
         return msg
 
 cmdtable = {}

          
@@ 118,7 106,10 @@ def dagwalker(repo, revs):
 ], inferrepo=True)
 def debuglairucremgraphlog(ui, repo, *pats, **opts):
     # Parameters are identical to log command ones
-    opts['graph'] = True
+    for key in list(opts.keys()):
+        if isinstance(key, str):
+            opts[key.encode('utf-8')] = opts.pop(key)
+    opts[b'graph'] = True
     revs, filematcher = getrevs(repo, pats, opts)[:2]
     revdag = dagwalker(repo, revs)
 

          
M lairucrem/process.py +1 -2
@@ 17,7 17,6 @@ from .exceptions import HgNotFoundError,
 
 #
 
-
 async def _wait_process(proc, cmd=''):
     """Wait for the process and handle error.
 

          
@@ 72,7 71,7 @@ class hg:
             if config.DEBUG:
                 args += ('--traceback',)
             args += self.args
-            self.cmd = ' '.join(args)
+            self.cmd = ' '.join(shlex.quote(a) for a in args)
             try:
                 self.proc = await asyncio.create_subprocess_exec(
                     *args, loop=asyncio.get_event_loop(), **self.kwargs

          
M lairucrem/utils.py +2 -1
@@ 100,6 100,7 @@ def parse_colored_line(
         out = []
     style, content = match.groups()
     style = style.strip()
+    style = style.split()[0]  # XXX
     # put back trailling ']' for nested colors
     content += line[match.regs[-1][-1]: end-1]
     # considere nested color syles or applys parent style if none note: we are

          
@@ 136,7 137,7 @@ class popup_error:
         if traceback:
             diag.append_button('traceback', 'traceback', key='?')
         res = await diag
-        if res is 'traceback':
+        if res == 'traceback':
             await self.display_traceback(exctype, traceback)
 
     async def display_traceback(self, exctype: Type, traceback):