From patchwork Sun Mar 12 17:22:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,9,py3] branchmap: don't use buffer() on Python 3 From: Augie Fackler X-Patchwork-Id: 19174 Message-Id: <062d30be868aad888f8d.1489339336@augie-macbookair2.roam.corp.google.com> To: mercurial-devel@mercurial-scm.org Date: Sun, 12 Mar 2017 13:22:16 -0400 # HG changeset patch # User Augie Fackler # Date 1489297759 18000 # Sun Mar 12 00:49:19 2017 -0500 # Node ID 062d30be868aad888f8d2e51d65999cb8c94b81a # Parent b9d20b6e86e011db2a11abccc26250c7a83e8aac branchmap: don't use buffer() on Python 3 This is certainly slower than the Python 2 code, but it works, and we can revisit it later if it's a problem. diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -19,6 +19,7 @@ from .node import ( from . import ( encoding, error, + pycompat, scmutil, util, ) @@ -408,8 +409,11 @@ class revbranchcache(object): # fast path: extract data from cache, use it if node is matching reponode = changelog.node(rev)[:_rbcnodelen] - cachenode, branchidx = unpack( - _rbcrecfmt, buffer(self._rbcrevs, rbcrevidx, _rbcrecsize)) + if pycompat.ispy3: + data = self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] + else: + data = buffer(self._rbcrevs, rbcrevidx, _rbcrecsize) + cachenode, branchidx = unpack(_rbcrecfmt, data) close = bool(branchidx & _rbccloseflag) if close: branchidx &= _rbcbranchidxmask