[PATCH 05 of 11] py3: make sure we use bytes in generate-working-copy-states.py

Pulkit Goyal 7895pulkit at gmail.com
Fri Feb 23 13:15:18 EST 2018


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1519386951 -19800
#      Fri Feb 23 17:25:51 2018 +0530
# Node ID 66968eaf19d62767cbdb446d0c173e67d5a925ce
# Parent  6610c379cb0f90d9dbdc787e3d7982fce07ded86
py3: make sure we use bytes in generate-working-copy-states.py

diff --git a/tests/generate-working-copy-states.py b/tests/generate-working-copy-states.py
--- a/tests/generate-working-copy-states.py
+++ b/tests/generate-working-copy-states.py
@@ -42,12 +42,12 @@ import sys
 def generatestates(maxchangesets, parentcontents):
     depth = len(parentcontents)
     if depth == maxchangesets + 1:
-        for tracked in ('untracked', 'tracked'):
-            filename = "_".join([(content is None and 'missing' or content) for
-                                 content in parentcontents]) + "-" + tracked
+        for tracked in (b'untracked', b'tracked'):
+            filename = b"_".join([(content is None and b'missing' or content)
+                                for content in parentcontents]) + b"-" + tracked
             yield (filename, parentcontents)
     else:
-        for content in ({None, 'content' + str(depth + 1)} |
+        for content in ({None, b'content' + (b"%d" % (depth + 1))} |
                       set(parentcontents)):
             for combination in generatestates(maxchangesets,
                                               parentcontents + [content]):
@@ -71,7 +71,7 @@ for filename, states in combinations:
         if depth == 'wc':
             # Make sure there is content so the file gets written and can be
             # tracked. It will be deleted outside of this script.
-            content.append((filename, states[maxchangesets] or 'TOBEDELETED'))
+            content.append((filename, states[maxchangesets] or b'TOBEDELETED'))
         else:
             content.append((filename, states[int(depth) - 1]))
     else:
@@ -82,7 +82,7 @@ for filename, states in combinations:
 for filename, data in content:
     if data is not None:
         f = open(filename, 'wb')
-        f.write(data + '\n')
+        f.write(data + b'\n')
         f.close()
     elif os.path.exists(filename):
         os.remove(filename)


More information about the Mercurial-devel mailing list