[PATCH 05 of 11] manifest: coerce _msearch argument to bytestr at method start

Augie Fackler raf at durin42.com
Sun Mar 26 18:36:39 EDT 2017


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1490567242 14400
#      Sun Mar 26 18:27:22 2017 -0400
# Node ID d5dcfa6b2e20183ba2d6e439a23f5f2f4bf7981e
# Parent  54631fab906cb662e370ce313a0395292f7dfa15
manifest: coerce _msearch argument to bytestr at method start

This potentially incurs some extra copies, but on Python 3 you can't
do comparisons between memoryview and bytes sequences. I have a
sneaking suspicion there are potential bugs in Python 2 lurking that
this might fix (but I have no way of proving this theory), so I'm not
going to sweat the risk of extra overhead here.

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -20,6 +20,7 @@ from . import (
     error,
     mdiff,
     parsers,
+    pycompat,
     revlog,
     util,
 )
@@ -652,6 +653,7 @@ def _msearch(m, s, lo=0, hi=None):
 
     m should be a buffer or a string
     s is a string'''
+    m = pycompat.bytestr(m)
     def advance(i, c):
         while i < lenm and m[i] != c:
             i += 1


More information about the Mercurial-devel mailing list