mercurial/manifest.py
changeset 31650 23391acfc421
parent 31531 326bca5477d0
child 31787 6bfea18df609
--- a/mercurial/manifest.py	Sun Mar 26 17:00:23 2017 -0700
+++ b/mercurial/manifest.py	Sun Mar 26 19:06:48 2017 +0900
@@ -650,10 +650,10 @@
     that string.  If start == end the string was not found and
     they indicate the proper sorted insertion point.
 
-    m should be a buffer or a string
-    s is a string'''
+    m should be a buffer, a memoryview or a byte string.
+    s is a byte string'''
     def advance(i, c):
-        while i < lenm and m[i] != c:
+        while i < lenm and m[i:i + 1] != c:
             i += 1
         return i
     if not s:
@@ -664,10 +664,10 @@
     while lo < hi:
         mid = (lo + hi) // 2
         start = mid
-        while start > 0 and m[start - 1] != '\n':
+        while start > 0 and m[start - 1:start] != '\n':
             start -= 1
         end = advance(start, '\0')
-        if m[start:end] < s:
+        if bytes(m[start:end]) < s:
             # we know that after the null there are 40 bytes of sha1
             # this translates to the bisect lo = mid + 1
             lo = advance(end + 40, '\n') + 1