changeset 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 1435a8e9b5fe
children 4b83507bfc91
files mercurial/branchmap.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Mon Mar 14 15:05:25 2016 +0000
+++ b/mercurial/branchmap.py	Sun Mar 13 02:06:21 2016 +0100
@@ -461,6 +461,8 @@
                         self._rbcnamescount = 0
                         self._rbcrevslen = 0
                 if self._rbcnamescount == 0:
+                    # before rewriting names, make sure references are removed
+                    repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True)
                     f = repo.vfs.open(_rbcnames, 'wb')
                 f.write('\0'.join(encoding.fromlocal(b)
                                   for b in self._names[self._rbcnamescount:]))