py3: add pycompat buffer alias

Summary: buffer in Python 2 became memoryview in Python 3.

Reviewed By: quark-zju

Differential Revision: D19717251

fbshipit-source-id: f678abfed7e2ec94053329b13015bff3c31eb319
This commit is contained in:
Durham Goode 2020-02-17 14:47:28 -08:00 committed by Facebook Github Bot
parent e4b5247311
commit 66fd50346c
2 changed files with 4 additions and 2 deletions

View File

@ -327,7 +327,7 @@ class shallowcg1packer(changegroup.cg1packer):
return results return results
def nodechunk(self, revlog, node, prevnode, linknode): def nodechunk(self, revlog, node, prevnode, linknode):
prefix = "" prefix = b""
if prevnode is not nullid and not revlog.candelta(prevnode, node): if prevnode is not nullid and not revlog.candelta(prevnode, node):
basenode = nullid basenode = nullid
else: else:
@ -525,7 +525,7 @@ def addchangegroupfiles(orig, repo, source, revmap, trp, expectedfiles, *args):
raise error.Abort("unexpected deltabase") raise error.Abort("unexpected deltabase")
base = reconstruct(f, deltabase) base = reconstruct(f, deltabase)
rawtext = mdiff.patch(base, delta) rawtext = mdiff.patch(base, delta)
if isinstance(rawtext, buffer): # noqa if isinstance(rawtext, pycompat.buffer): # noqa
rawtext = bytes(rawtext) rawtext = bytes(rawtext)
return rawtext return rawtext

View File

@ -96,6 +96,7 @@ if sys.version_info[0] >= 3:
bytechr = chr bytechr = chr
bytestr = str bytestr = str
buffer = memoryview
def raisewithtb(exc, tb): def raisewithtb(exc, tb):
"""Raise exception with the given traceback""" """Raise exception with the given traceback"""
@ -143,6 +144,7 @@ else:
bytechr = chr bytechr = chr
bytestr = str bytestr = str
buffer = buffer
range = xrange # noqa: F821 range = xrange # noqa: F821
unicode = unicode unicode = unicode