Patchwork [3,of,4,py3] manifest: fix some pure-Python parser bits to work on Python 3

login
register
mail settings
Submitter Augie Fackler
Date May 29, 2017, 1:43 a.m.
Message ID <d7743001547ef1de5657.1496022184@imladris.local>
Download mbox | patch
Permalink /patch/21026/
State Accepted
Headers show

Comments

Augie Fackler - May 29, 2017, 1:43 a.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1496021355 14400
#      Sun May 28 21:29:15 2017 -0400
# Node ID d7743001547ef1de565717cebf7e88e31e60433c
# Parent  221e447c9410325c4051e61e762e2afd871a9b0f
manifest: fix some pure-Python parser bits to work on Python 3

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -33,7 +33,7 @@  def _parsev1(data):
     # class exactly matches its C counterpart to try and help
     # prevent surprise breakage for anyone that develops against
     # the pure version.
-    if data and data[-1] != '\n':
+    if data and data[-1:] != '\n':
         raise ValueError('Manifest did not end in a newline.')
     prev = None
     for l in data.splitlines():
@@ -55,7 +55,7 @@  def _parsev2(data):
         end = data.find('\n', pos + 1) # +1 to skip stem length byte
         if end == -1:
             raise ValueError('Manifest ended with incomplete file entry.')
-        stemlen = ord(data[pos])
+        stemlen = ord(data[pos:pos + 1])
         items = data[pos + 1:end].split('\0')
         f = prevf[:stemlen] + items[0]
         if prevf > f: