Mercurial > hg-stable
diff mercurial/branchmap.py @ 31355:2a18e9e6ca43
py3: use bytearray() instead of array('c', ...) constructions
Portable from 2.6-3.6.
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 12 Mar 2017 03:32:21 -0400 |
parents | 22fbca1d11ed |
children | 279430eeefdb |
line wrap: on
line diff
--- a/mercurial/branchmap.py Sat Mar 11 20:58:26 2017 -0500 +++ b/mercurial/branchmap.py Sun Mar 12 03:32:21 2017 -0400 @@ -357,7 +357,7 @@ assert repo.filtername is None self._repo = repo self._names = [] # branch names in local encoding with static index - self._rbcrevs = array('c') # structs of type _rbcrecfmt + self._rbcrevs = bytearray() self._rbcsnameslen = 0 # length of names read at _rbcsnameslen try: bndata = repo.vfs.read(_rbcnames) @@ -371,7 +371,7 @@ if self._names: try: data = repo.vfs.read(_rbcrevs) - self._rbcrevs.fromstring(data) + self._rbcrevs[:] = data except (IOError, OSError) as inst: repo.ui.debug("couldn't read revision branch cache: %s\n" % inst) @@ -390,8 +390,7 @@ self._rbcnamescount = 0 self._namesreverse.clear() self._rbcrevslen = len(self._repo.changelog) - self._rbcrevs = array('c') - self._rbcrevs.fromstring('\0' * (self._rbcrevslen * _rbcrecsize)) + self._rbcrevs = bytearray(self._rbcrevslen * _rbcrecsize) def branchinfo(self, rev): """Return branch name and close flag for rev, using and updating @@ -454,8 +453,7 @@ def _setcachedata(self, rev, node, branchidx): """Writes the node's branch data to the in-memory cache data.""" rbcrevidx = rev * _rbcrecsize - rec = array('c') - rec.fromstring(pack(_rbcrecfmt, node, branchidx)) + rec = bytearray(pack(_rbcrecfmt, node, branchidx)) if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: self._rbcrevs.extend('\0' * (len(self._repo.changelog) * _rbcrecsize -