changeset 41326:7c54357be2ae

tests: normalize XML values to bytes This fixes some type mismatches. The encoding shouldn't matter for what this script is used for. UTF-8 seems reasonable, especially since I'm pretty sure SVN will emit UTF-8 encoded XML. Differential Revision: https://phab.mercurial-scm.org/D5665
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 23 Jan 2019 16:22:54 -0800
parents eff0a7d3229c
children 1281b2265ff5
files tests/svnxml.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/tests/svnxml.py	Wed Jan 23 17:26:00 2019 -0800
+++ b/tests/svnxml.py	Wed Jan 23 16:22:54 2019 -0800
@@ -20,10 +20,10 @@
     if paths:
         paths = paths[0]
         for p in paths.getElementsByTagName('path'):
-            action = p.getAttribute('action')
-            path = xmltext(p)
-            frompath = p.getAttribute('copyfrom-path')
-            fromrev = p.getAttribute('copyfrom-rev')
+            action = p.getAttribute('action').encode('utf-8')
+            path = xmltext(p).encode('utf-8')
+            frompath = p.getAttribute('copyfrom-path').encode('utf-8')
+            fromrev = p.getAttribute('copyfrom-rev').encode('utf-8')
             e['paths'].append((path, action, frompath, fromrev))
     return e
 
@@ -43,11 +43,11 @@
         for k in ('revision', 'author', 'msg'):
             fp.write(('%s: %s\n' % (k, e[k])).encode('utf-8'))
         for path, action, fpath, frev in sorted(e['paths']):
-            frominfo = ''
+            frominfo = b''
             if frev:
-                frominfo = ' (from %s@%s)' % (fpath, frev)
-            p = ' %s %s%s\n' % (action, path, frominfo)
-            fp.write(p.encode('utf-8'))
+                frominfo = b' (from %s@%s)' % (fpath, frev)
+            p = b' %s %s%s\n' % (action, path, frominfo)
+            fp.write(p)
 
 if __name__ == '__main__':
     data = sys.stdin.read()