Show More
@@ -2190,6 +2190,13 b' class revlog(object):' | |||||
2190 | fp.write(e) |
|
2190 | fp.write(e) | |
2191 | if self._docket is not None: |
|
2191 | if self._docket is not None: | |
2192 | self._docket.index_end = fp.tell() |
|
2192 | self._docket.index_end = fp.tell() | |
|
2193 | ||||
|
2194 | # There is a small transactional race here. If the rename of | |||
|
2195 | # the index fails, we should remove the datafile. It is more | |||
|
2196 | # important to ensure that the data file is not truncated | |||
|
2197 | # when the index is replaced as otherwise data is lost. | |||
|
2198 | tr.replace(self._datafile, self.start(trindex)) | |||
|
2199 | ||||
2193 | # the temp file replace the real index when we exit the context |
|
2200 | # the temp file replace the real index when we exit the context | |
2194 | # manager |
|
2201 | # manager | |
2195 |
|
2202 |
@@ -1,7 +1,27 b'' | |||||
1 | Test correctness of revlog inline -> non-inline transition |
|
1 | Test correctness of revlog inline -> non-inline transition | |
2 | ---------------------------------------------------------- |
|
2 | ---------------------------------------------------------- | |
3 |
|
3 | |||
|
4 | Helper extension to intercept renames. | |||
|
5 | ||||
|
6 | $ cat > $TESTTMP/intercept_rename.py << EOF | |||
|
7 | > import os | |||
|
8 | > import sys | |||
|
9 | > from mercurial import extensions, util | |||
|
10 | > | |||
|
11 | > def extsetup(ui): | |||
|
12 | > def close(orig, *args, **kwargs): | |||
|
13 | > path = args[0]._atomictempfile__name | |||
|
14 | > if path.endswith(b'/.hg/store/data/file.i'): | |||
|
15 | > os._exit(80) | |||
|
16 | > return orig(*args, **kwargs) | |||
|
17 | > extensions.wrapfunction(util.atomictempfile, 'close', close) | |||
|
18 | > EOF | |||
|
19 | ||||
|
20 | ||||
4 | Test offset computation to correctly factor in the index entries themselve. |
|
21 | Test offset computation to correctly factor in the index entries themselve. | |
|
22 | Also test that the new data size has the correct size if the transaction is aborted | |||
|
23 | after the index has been replaced. | |||
|
24 | ||||
5 | Test repo has one small, one moderate and one big change. The clone has |
|
25 | Test repo has one small, one moderate and one big change. The clone has | |
6 | the small and moderate change and will transition to non-inline storage when |
|
26 | the small and moderate change and will transition to non-inline storage when | |
7 | adding the big change. |
|
27 | adding the big change. | |
@@ -18,6 +38,12 b' adding the big change.' | |||||
18 |
|
38 | |||
19 | $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q |
|
39 | $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q | |
20 | $ cd troffset-computation-copy |
|
40 | $ cd troffset-computation-copy | |
|
41 | ||||
|
42 | Reference size: | |||
|
43 | ||||
|
44 | $ f -s .hg/store/data/file* | |||
|
45 | .hg/store/data/file.i: size=1174 | |||
|
46 | ||||
21 | $ cat > .hg/hgrc <<EOF |
|
47 | $ cat > .hg/hgrc <<EOF | |
22 | > [hooks] |
|
48 | > [hooks] | |
23 | > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme |
|
49 | > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme | |
@@ -25,5 +51,36 b' adding the big change.' | |||||
25 | $ hg pull ../troffset-computation |
|
51 | $ hg pull ../troffset-computation | |
26 | pulling from ../troffset-computation |
|
52 | pulling from ../troffset-computation | |
27 | [80] |
|
53 | [80] | |
28 | $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1 |
|
54 | ||
|
55 | The first file.i entry should match the size above. | |||
|
56 | The first file.d entry is the temporary record during the split, | |||
|
57 | the second entry after the split happened. The sum of the second file.d | |||
|
58 | and the second file.i entry should match the first file.i entry. | |||
|
59 | ||||
|
60 | $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | |||
|
61 | data/file.i 1174 | |||
|
62 | data/file.d 0 | |||
|
63 | data/file.d 1046 | |||
29 | data/file.i 128 |
|
64 | data/file.i 128 | |
|
65 | $ cd .. | |||
|
66 | ||||
|
67 | Now retry the same but intercept the rename of the index and check that | |||
|
68 | the journal does not contain the new index size. This demonstrates the edge case | |||
|
69 | where the data file is left as garbage. | |||
|
70 | ||||
|
71 | $ hg clone -r 1 troffset-computation troffset-computation-copy2 --config format.revlog-compression=none -q | |||
|
72 | $ cd troffset-computation-copy2 | |||
|
73 | $ cat > .hg/hgrc <<EOF | |||
|
74 | > [extensions] | |||
|
75 | > intercept_rename = $TESTTMP/intercept_rename.py | |||
|
76 | > [hooks] | |||
|
77 | > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme | |||
|
78 | > EOF | |||
|
79 | $ hg pull ../troffset-computation | |||
|
80 | pulling from ../troffset-computation | |||
|
81 | [80] | |||
|
82 | $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | |||
|
83 | data/file.i 1174 | |||
|
84 | data/file.d 0 | |||
|
85 | data/file.d 1046 | |||
|
86 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now