Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 50659:12f13b13f414 stable
revlog: avoid possible collision between directory and temporary index
Since 6.4, we create a temporary index file to write the split data without
overwriting the inline version too early. However, the store encoding does not
prevent these new `.i.s` file to collide with a directory with the same name.
While the odds for such a collision to happens are fairly low, the collision
would prevent Mercurial from working.
The store encoding have a mitigation solution in place to prevent such
collisions from happening for `.i` and `.d` files, but not for other extensions.
We cannot update this encoding scheme to solve the issue since it would diverge
from older version of Mercurial.
Instead, we create an alternative directory tree dedicated to such files.
The use of the `.i` extension combined with store encoding will prevent
collisions there.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 08 Jun 2023 14:28:21 +0200 |
parents | 978ffa09910b |
children | a41eeb877d07 |
comparison
equal
deleted
inserted
replaced
50658:978ffa09910b | 50659:12f13b13f414 |
---|---|
2024 def _split_index_file(self): | 2024 def _split_index_file(self): |
2025 """the path where to expect the index of an ongoing splitting operation | 2025 """the path where to expect the index of an ongoing splitting operation |
2026 | 2026 |
2027 The file will only exist if a splitting operation is in progress, but | 2027 The file will only exist if a splitting operation is in progress, but |
2028 it is always expected at the same location.""" | 2028 it is always expected at the same location.""" |
2029 return self.radix + b'.i.s' | 2029 parts = os.path.split(self.radix) |
2030 if len(parts) > 1: | |
2031 # adds a '-s' prefix to the ``data/` or `meta/` base | |
2032 head = parts[0] + b'-s' | |
2033 return os.path.join(head, *parts[1:]) | |
2034 else: | |
2035 # the revlog is stored at the root of the store (changelog or | |
2036 # manifest), no risk of collision. | |
2037 return self.radix + b'.i.s' | |
2030 | 2038 |
2031 def _enforceinlinesize(self, tr, side_write=True): | 2039 def _enforceinlinesize(self, tr, side_write=True): |
2032 """Check if the revlog is too big for inline and convert if so. | 2040 """Check if the revlog is too big for inline and convert if so. |
2033 | 2041 |
2034 This should be called after revisions are added to the revlog. If the | 2042 This should be called after revisions are added to the revlog. If the |