Skip to content
Snippets Groups Projects
Commit bfbd84c5 authored by Arseniy Alekseyev's avatar Arseniy Alekseyev
Browse files

dirstate-v2: actually fix the dirstate-v2 upgrade race

It looks like the previous fix for the dirstate-v2 upgrade race didn't work.
The problem is that it only recovers in case the size of the v1 `dirstate` file
is smaller than the `v2` one, whereas in real life it's always larger.

This commit changes the test to be more realistic, which reveals the crash,
and changes the code to fix the crash.
parent 42f761e9
No related branches found
No related tags found
2 merge requests!634merge stable into default,!623dirstate-v2: actually fix the dirstate-v2 upgrade race
......@@ -4,7 +4,6 @@
# GNU General Public License version 2 or any later version.
import struct
from .i18n import _
from . import (
......@@ -152,5 +151,6 @@
b'dirstate only has a docket in v2 format'
)
self._set_identity()
try:
data = self._readdirstatefile()
if data == b'' or data.startswith(docketmod.V2_FORMAT_MARKER):
self._docket = docketmod.DirstateDocket.parse(
......@@ -156,3 +156,3 @@
self._docket = docketmod.DirstateDocket.parse(
self._readdirstatefile(), self._nodeconstants
data, self._nodeconstants
)
......@@ -158,9 +158,6 @@
)
except struct.error:
self._ui.debug(b"failed to read dirstate-v2 data")
raise error.CorruptedDirstate(
b"failed to read dirstate-v2 data"
)
else:
raise error.CorruptedDirstate(b"dirstate is not in v2 format")
return self._docket
def _read_v2_data(self):
......
......@@ -10,8 +10,8 @@
$ hg init repo
$ cd repo
$ echo a > a
$ hg add a
$ hg commit -m a
$ touch file-with-somewhat-long-name-to-make-dirstate-v1-bigger-than-v2
$ hg commit -Aqm a
$ hg debugrequires | grep dirstate
[1]
$ ls -1 .hg/dirstate*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment