py3: use list of bytes rather than bytestring while extending bytes into lists
Python 2:
>>> ls = []
>>> ls.extend(b'abc')
>>> ls
['a', 'b', 'c']
Python 3:
>>> ls = []
>>> ls.extend(b'abc')
>>> ls
[97, 98, 99]
So to make sure things work fine in Py3, this patch does:
>>> ls = []
>>> ls.extend([b'a', b'b', b'c'])
>>> ls
[b'a', b'b', b'c']
After this `hg log -G` works!
--- a/mercurial/graphmod.py Thu May 04 01:12:14 2017 +0530
+++ b/mercurial/graphmod.py Thu May 04 04:38:20 2017 +0530
@@ -273,7 +273,7 @@
# | | | | | |
line.extend(echars[idx * 2:(idx + 1) * 2])
else:
- line.extend(' ')
+ line.extend([' ', ' '])
# all edges to the right of the current node
remainder = ncols - idx - 1
if remainder > 0:
@@ -410,14 +410,17 @@
# shift_interline is the line containing the non-vertical
# edges between this entry and the next
shift_interline = echars[:idx * 2]
- shift_interline.extend(' ' * (2 + coldiff))
+ for i in xrange(2 + coldiff):
+ shift_interline.append(' ')
count = ncols - idx - 1
if coldiff == -1:
- shift_interline.extend('/ ' * count)
+ for i in xrange(count):
+ shift_interline.extend(['/', ' '])
elif coldiff == 0:
shift_interline.extend(echars[(idx + 1) * 2:ncols * 2])
else:
- shift_interline.extend(r'\ ' * count)
+ for i in xrange(count):
+ shift_interline.extend(['\\', ' '])
# draw edges from the current node to its parents
_drawedges(echars, edges, nodeline, shift_interline)