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