[PATCH 07 of 10] py3: use list of bytes rather than bytestring while extending bytes into lists

Pulkit Goyal 7895pulkit at gmail.com
Thu May 4 18:46:52 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1493852900 -19800
#      Thu May 04 04:38:20 2017 +0530
# Node ID 4d0d30dadcc8bd2267c1503d84d0b46778652736
# Parent  465fc9fb716a6c48ad9e39eb757443619b3f750d
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!

diff -r 465fc9fb716a -r 4d0d30dadcc8 mercurial/graphmod.py
--- 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)


More information about the Mercurial-devel mailing list