##// END OF EJS Templates
py3: use bytearray() instead of array('c', ...) constructions...
Augie Fackler -
r31346:2a18e9e6 default
parent child Browse files
Show More
@@ -357,7 +357,7 b' class revbranchcache(object):'
357 357 assert repo.filtername is None
358 358 self._repo = repo
359 359 self._names = [] # branch names in local encoding with static index
360 self._rbcrevs = array('c') # structs of type _rbcrecfmt
360 self._rbcrevs = bytearray()
361 361 self._rbcsnameslen = 0 # length of names read at _rbcsnameslen
362 362 try:
363 363 bndata = repo.vfs.read(_rbcnames)
@@ -371,7 +371,7 b' class revbranchcache(object):'
371 371 if self._names:
372 372 try:
373 373 data = repo.vfs.read(_rbcrevs)
374 self._rbcrevs.fromstring(data)
374 self._rbcrevs[:] = data
375 375 except (IOError, OSError) as inst:
376 376 repo.ui.debug("couldn't read revision branch cache: %s\n" %
377 377 inst)
@@ -390,8 +390,7 b' class revbranchcache(object):'
390 390 self._rbcnamescount = 0
391 391 self._namesreverse.clear()
392 392 self._rbcrevslen = len(self._repo.changelog)
393 self._rbcrevs = array('c')
394 self._rbcrevs.fromstring('\0' * (self._rbcrevslen * _rbcrecsize))
393 self._rbcrevs = bytearray(self._rbcrevslen * _rbcrecsize)
395 394
396 395 def branchinfo(self, rev):
397 396 """Return branch name and close flag for rev, using and updating
@@ -454,8 +453,7 b' class revbranchcache(object):'
454 453 def _setcachedata(self, rev, node, branchidx):
455 454 """Writes the node's branch data to the in-memory cache data."""
456 455 rbcrevidx = rev * _rbcrecsize
457 rec = array('c')
458 rec.fromstring(pack(_rbcrecfmt, node, branchidx))
456 rec = bytearray(pack(_rbcrecfmt, node, branchidx))
459 457 if len(self._rbcrevs) < rbcrevidx + _rbcrecsize:
460 458 self._rbcrevs.extend('\0' *
461 459 (len(self._repo.changelog) * _rbcrecsize -
@@ -209,7 +209,7 b' class bundlemanifest(bundlerevlog, manif'
209 209 node = self.node(node)
210 210
211 211 if node in self.fulltextcache:
212 result = self.fulltextcache[node].tostring()
212 result = '%s' % self.fulltextcache[node]
213 213 else:
214 214 result = manifest.manifestrevlog.revision(self, nodeorrev)
215 215 return result
@@ -7,7 +7,6 b''
7 7
8 8 from __future__ import absolute_import
9 9
10 import array
11 10 import heapq
12 11 import os
13 12 import struct
@@ -628,8 +627,9 b' class manifestdict(object):'
628 627 else:
629 628 # For large changes, it's much cheaper to just build the text and
630 629 # diff it.
631 arraytext = array.array('c', self.text())
632 deltatext = mdiff.textdiff(base, arraytext)
630 arraytext = bytearray(self.text())
631 deltatext = mdiff.textdiff(
632 util.buffer(base), util.buffer(arraytext))
633 633
634 634 return arraytext, deltatext
635 635
@@ -687,12 +687,12 b' def _addlistdelta(addlist, x):'
687 687 # for large addlist arrays, building a new array is cheaper
688 688 # than repeatedly modifying the existing one
689 689 currentposition = 0
690 newaddlist = array.array('c')
690 newaddlist = bytearray()
691 691
692 692 for start, end, content in x:
693 693 newaddlist += addlist[currentposition:start]
694 694 if content:
695 newaddlist += array.array('c', content)
695 newaddlist += bytearray(content)
696 696
697 697 currentposition = end
698 698
@@ -1240,7 +1240,7 b' class manifestrevlog(revlog.revlog):'
1240 1240 else:
1241 1241 text = m.text(self._usemanifestv2)
1242 1242 n = self.addrevision(text, transaction, link, p1, p2)
1243 arraytext = array.array('c', text)
1243 arraytext = bytearray(text)
1244 1244
1245 1245 if arraytext is not None:
1246 1246 self.fulltextcache[n] = arraytext
@@ -1420,7 +1420,7 b' class manifestctx(object):'
1420 1420 else:
1421 1421 rl = self._revlog()
1422 1422 text = rl.revision(self._node)
1423 arraytext = array.array('c', text)
1423 arraytext = bytearray(text)
1424 1424 rl._fulltextcache[self._node] = arraytext
1425 1425 self._data = manifestdict(text)
1426 1426 return self._data
@@ -1529,7 +1529,7 b' class treemanifestctx(object):'
1529 1529 self._data = m
1530 1530 else:
1531 1531 text = rl.revision(self._node)
1532 arraytext = array.array('c', text)
1532 arraytext = bytearray(text)
1533 1533 rl.fulltextcache[self._node] = arraytext
1534 1534 self._data = treemanifest(dir=self._dir, text=text)
1535 1535
@@ -428,13 +428,12 b' class hgtagsfnodescache(object):'
428 428 self.lookupcount = 0
429 429 self.hitcount = 0
430 430
431 self._raw = array('c')
432 431
433 432 try:
434 433 data = repo.vfs.read(_fnodescachefile)
435 434 except (OSError, IOError):
436 435 data = ""
437 self._raw.fromstring(data)
436 self._raw = bytearray(data)
438 437
439 438 # The end state of self._raw is an array that is of the exact length
440 439 # required to hold a record for every revision in the repository.
@@ -475,7 +474,7 b' class hgtagsfnodescache(object):'
475 474 self.lookupcount += 1
476 475
477 476 offset = rev * _fnodesrecsize
478 record = self._raw[offset:offset + _fnodesrecsize].tostring()
477 record = '%s' % self._raw[offset:offset + _fnodesrecsize]
479 478 properprefix = node[0:4]
480 479
481 480 # Validate and return existing entry.
@@ -516,7 +515,7 b' class hgtagsfnodescache(object):'
516 515
517 516 def _writeentry(self, offset, prefix, fnode):
518 517 # Slices on array instances only accept other array.
519 entry = array('c', prefix + fnode)
518 entry = bytearray(prefix + fnode)
520 519 self._raw[offset:offset + _fnodesrecsize] = entry
521 520 # self._dirtyoffset could be None.
522 521 self._dirtyoffset = min(self._dirtyoffset, offset) or 0
General Comments 0
You need to be logged in to leave comments. Login now