Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/branchmap.py @ 28556:0706d60d070f
cache: remove branch revision file before rewriting the branch name file
New branch names are usually appended to the branch name file. If that fails or
the file has been modified by another process, it is rewritten. That left a
small opportunity that there could be references to non-existent entries in the
file while it was rewritten.
To avoid that, remove the revision branch cache file with the references to the
branch name file before rewriting the branch name file. Worst case, when
interrupted at the wrong time, the cache will be lost and rebuilt next time.
It is unknown if this fixes a real problem that ever happened.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Sun, 13 Mar 2016 02:06:21 +0100 |
parents | f1460af18c50 |
children | 4b83507bfc91 |
comparison
equal
deleted
inserted
replaced
28555:1435a8e9b5fe | 28556:0706d60d070f |
---|---|
459 f.close() | 459 f.close() |
460 repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) | 460 repo.ui.debug("%s changed - rewriting it\n" % _rbcnames) |
461 self._rbcnamescount = 0 | 461 self._rbcnamescount = 0 |
462 self._rbcrevslen = 0 | 462 self._rbcrevslen = 0 |
463 if self._rbcnamescount == 0: | 463 if self._rbcnamescount == 0: |
464 # before rewriting names, make sure references are removed | |
465 repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True) | |
464 f = repo.vfs.open(_rbcnames, 'wb') | 466 f = repo.vfs.open(_rbcnames, 'wb') |
465 f.write('\0'.join(encoding.fromlocal(b) | 467 f.write('\0'.join(encoding.fromlocal(b) |
466 for b in self._names[self._rbcnamescount:])) | 468 for b in self._names[self._rbcnamescount:])) |
467 self._rbcsnameslen = f.tell() | 469 self._rbcsnameslen = f.tell() |
468 f.close() | 470 f.close() |