Show More
@@ -470,48 +470,54 b' class revbranchcache(object):' | |||||
470 | def write(self, tr=None): |
|
470 | def write(self, tr=None): | |
471 | """Save branch cache if it is dirty.""" |
|
471 | """Save branch cache if it is dirty.""" | |
472 | repo = self._repo |
|
472 | repo = self._repo | |
473 | if self._rbcnamescount < len(self._names): |
|
473 | if True: | |
474 | try: |
|
474 | if self._rbcnamescount < len(self._names): | |
475 | if self._rbcnamescount != 0: |
|
475 | try: | |
476 |
f |
|
476 | if self._rbcnamescount != 0: | |
477 |
|
|
477 | f = repo.vfs.open(_rbcnames, 'ab') | |
478 |
f. |
|
478 | if f.tell() == self._rbcsnameslen: | |
479 |
|
|
479 | f.write('\0') | |
480 |
|
|
480 | else: | |
481 | repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) |
|
481 | f.close() | |
482 | self._rbcnamescount = 0 |
|
482 | repo.ui.debug("%s changed - rewriting it\n" | |
483 |
|
|
483 | % _rbcnames) | |
484 |
|
|
484 | self._rbcnamescount = 0 | |
485 | # before rewriting names, make sure references are removed |
|
485 | self._rbcrevslen = 0 | |
486 | repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True) |
|
486 | if self._rbcnamescount == 0: | |
487 | f = repo.vfs.open(_rbcnames, 'wb') |
|
487 | # before rewriting names, make sure references are | |
488 | f.write('\0'.join(encoding.fromlocal(b) |
|
488 | # removed | |
489 | for b in self._names[self._rbcnamescount:])) |
|
489 | repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True) | |
490 | self._rbcsnameslen = f.tell() |
|
490 | f = repo.vfs.open(_rbcnames, 'wb') | |
491 | f.close() |
|
491 | f.write('\0'.join(encoding.fromlocal(b) | |
492 | except (IOError, OSError, error.Abort) as inst: |
|
492 | for b in self._names[self._rbcnamescount:] | |
493 | repo.ui.debug("couldn't write revision branch cache names: " |
|
493 | )) | |
494 | "%s\n" % inst) |
|
494 | self._rbcsnameslen = f.tell() | |
495 |
|
|
495 | f.close() | |
496 | self._rbcnamescount = len(self._names) |
|
496 | except (IOError, OSError, error.Abort) as inst: | |
|
497 | repo.ui.debug("couldn't write revision branch cache names: " | |||
|
498 | "%s\n" % inst) | |||
|
499 | return | |||
|
500 | self._rbcnamescount = len(self._names) | |||
497 |
|
501 | |||
498 | start = self._rbcrevslen * _rbcrecsize |
|
502 | start = self._rbcrevslen * _rbcrecsize | |
499 | if start != len(self._rbcrevs): |
|
503 | if start != len(self._rbcrevs): | |
500 |
revs = min(len(repo.changelog), |
|
504 | revs = min(len(repo.changelog), | |
501 | try: |
|
505 | len(self._rbcrevs) // _rbcrecsize) | |
502 | f = repo.vfs.open(_rbcrevs, 'ab') |
|
506 | try: | |
503 | if f.tell() != start: |
|
507 | f = repo.vfs.open(_rbcrevs, 'ab') | |
504 | repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start)) |
|
|||
505 | f.seek(start) |
|
|||
506 | if f.tell() != start: |
|
508 | if f.tell() != start: | |
507 | start = 0 |
|
509 | repo.ui.debug("truncating %s to %s\n" | |
|
510 | % (_rbcrevs, start)) | |||
508 | f.seek(start) |
|
511 | f.seek(start) | |
509 |
f. |
|
512 | if f.tell() != start: | |
510 | end = revs * _rbcrecsize |
|
513 | start = 0 | |
511 |
f. |
|
514 | f.seek(start) | |
512 |
f. |
|
515 | f.truncate() | |
513 | except (IOError, OSError, error.Abort) as inst: |
|
516 | end = revs * _rbcrecsize | |
514 | repo.ui.debug("couldn't write revision branch cache: %s\n" % |
|
517 | f.write(self._rbcrevs[start:end]) | |
515 |
|
|
518 | f.close() | |
516 | return |
|
519 | except (IOError, OSError, error.Abort) as inst: | |
517 | self._rbcrevslen = revs |
|
520 | repo.ui.debug("couldn't write revision branch cache: %s\n" % | |
|
521 | inst) | |||
|
522 | return | |||
|
523 | self._rbcrevslen = revs |
General Comments 0
You need to be logged in to leave comments.
Login now