# HG changeset patch # User Matt Harbison <matt_harbi...@yahoo.com> # Date 1538269069 14400 # Sat Sep 29 20:57:49 2018 -0400 # Node ID 1dd7c3dcfb46a39bc61419415c0818e0ed1bbd1c # Parent 32349019b1ed3beae780cfe4c628d71714c6f675 py3: byteify windows.shelltocmdexe()
This makes test-doctest.py happy on Windows. diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -314,7 +314,7 @@ def shelltocmdexe(path, env): index = 0 pathlen = len(path) while index < pathlen: - c = path[index] + c = path[index:index + 1] if c == b'\'': # no expansion within single quotes path = path[index + 1:] pathlen = len(path) @@ -344,7 +344,7 @@ def shelltocmdexe(path, env): var = path[:index] # See below for why empty variables are handled specially - if env.get(var, '') != '': + if env.get(var, b'') != b'': res += b'%' + var + b'%' else: res += b'${' + var + b'}' @@ -365,20 +365,20 @@ def shelltocmdexe(path, env): # VAR, and that really confuses things like revset expressions. # OTOH, if it's left in Unix format and the hook runs sh.exe, it # will substitute to an empty string, and everything is happy. - if env.get(var, '') != '': + if env.get(var, b'') != b'': res += b'%' + var + b'%' else: res += b'$' + var - if c != '': + if c != b'': index -= 1 elif (c == b'~' and index + 1 < pathlen - and path[index + 1] in (b'\\', b'/')): + and path[index + 1:index + 2] in (b'\\', b'/')): res += "%USERPROFILE%" elif (c == b'\\' and index + 1 < pathlen - and path[index + 1] in (b'$', b'~')): + and path[index + 1:index + 2] in (b'$', b'~')): # Skip '\', but only if it is escaping $ or ~ - res += path[index + 1] + res += path[index + 1:index + 2] index += 1 else: res += c _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel