Mercurial > hg
annotate tests/test-manifestv2.t @ 26631:e077ce385609
localrepo: restore dirstate to one before rollbacking if not parent-gone
'localrepository.rollback()' explicilty restores dirstate, only if at
least one of current parents of the working directory is removed at
rollbacking (a.k.a "parent-gone").
After DirstateTransactionPlan, 'dirstate.write()' will cause marking
'.hg/dirstate' as a file to be restored at rollbacking.
https://mercurial.selenic.com/wiki/DirstateTransactionPlan
Then, 'transaction.rollback()' restores '.hg/dirstate' regardless of
parents of the working directory at that time, and this causes
unexpected dirstate changes if not "parent-gone" (e.g. "hg update" to
another branch after "hg commit" or so, then "hg rollback").
To avoid such situation, this patch restores dirstate to one before
rollbacking if not "parent-gone".
before:
b1. restore dirstate explicitly, if "parent-gone"
after:
a1. save dirstate before actual rollbacking via dirstateguard
a2. restore dirstate via 'transaction.rollback()'
a3. if "parent-gone"
- discard backup (a1)
- restore dirstate from 'undo.dirstate'
a4. otherwise, restore dirstate from backup (a1)
Even though restoring dirstate at (a3) after (a2) seems redundant,
this patch keeps this existing code path, because:
- it isn't ensured that 'dirstate.write()' was invoked at least once
while transaction running
If not, '.hg/dirstate' isn't restored at (a2).
In addition to it, rude 3rd party extension invoking
'dirstate.write()' without 'repo' while transaction running (see
subsequent patches for detail) may break consistency of a file
backup-ed by transaction.
- this patch mainly focuses on changes for DirstateTransactionPlan
Restoring dirstate at (a3) itself should be cheaper enough than
rollbacking itself. Redundancy will be removed in next step.
Newly added test is almost meaningless at this point. It will be used
to detect regression while implementing delayed dirstate write out.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 13 Oct 2015 12:25:43 -0700 |
parents | 3035b75cd594 |
children | 2329ca3ebc7a |
rev | line source |
---|---|
24935
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
1 Create repo with old manifest |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
2 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
3 $ hg init existing |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
4 $ cd existing |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
5 $ echo footext > foo |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
6 $ hg add foo |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
7 $ hg commit -m initial |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
8 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
9 We're using v1, so no manifestv2 entry is in requires yet. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
10 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
11 $ grep manifestv2 .hg/requires |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
12 [1] |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
13 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
14 Let's clone this with manifestv2 enabled to switch to the new format for |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
15 future commits. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
16 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
17 $ cd .. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
18 $ hg clone --pull existing new --config experimental.manifestv2=1 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
19 requesting all changes |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
20 adding changesets |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
21 adding manifests |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
22 adding file changes |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
23 added 1 changesets with 1 changes to 1 files |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
24 updating to branch default |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
25 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
26 $ cd new |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
27 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
28 Check that entry was added to .hg/requires. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
29 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
30 $ grep manifestv2 .hg/requires |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
31 manifestv2 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
32 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
33 Make a new commit. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
34 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
35 $ echo newfootext > foo |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
36 $ hg commit -m new |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
37 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
38 Check that the manifest actually switched to v2. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
39 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
40 $ hg debugdata -m 0 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
41 foo\x0021e958b1dca695a60ee2e9cf151753204ee0f9e9 (esc) |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
42 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
43 $ hg debugdata -m 1 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
44 \x00 (esc) |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
45 \x00foo\x00 (esc) |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
46 I\xab\x7f\xb8(\x83\xcas\x15\x9d\xc2\xd3\xd3:5\x08\xbad5_ (esc) |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
47 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
48 Check that manifestv2 is used if the requirement is present, even if it's |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
49 disabled in the config. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
50 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
51 $ echo newerfootext > foo |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
52 $ hg --config experimental.manifestv2=False commit -m newer |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
53 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
54 $ hg debugdata -m 2 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
55 \x00 (esc) |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
56 \x00foo\x00 (esc) |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
57 \xa6\xb1\xfb\xef]\x91\xa1\x19`\xf3.#\x90S\xf8\x06 \xe2\x19\x00 (esc) |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
58 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
59 Check that we can still read v1 manifests. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
60 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
61 $ hg files -r 0 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
62 foo |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
63 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
64 $ cd .. |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
65 |
3035b75cd594
tests: test that we can convert to manifestv2 with clone
Drew Gottlieb <drgott@google.com>
parents:
24573
diff
changeset
|
66 Check that entry is added to .hg/requires on repo creation |
24571
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
67 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
68 $ hg --config experimental.manifestv2=True init repo |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
69 $ cd repo |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
70 $ grep manifestv2 .hg/requires |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
71 manifestv2 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
72 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
73 Set up simple repo |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
74 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
75 $ echo a > file1 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
76 $ echo b > file2 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
77 $ echo c > file3 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
78 $ hg ci -Aqm 'initial' |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
79 $ echo d > file2 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
80 $ hg ci -m 'modify file2' |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
81 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
82 Check that 'hg verify', which uses manifest.readdelta(), works |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
83 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
84 $ hg verify |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
85 checking changesets |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
86 checking manifests |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
87 crosschecking files in changesets and manifests |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
88 checking files |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
89 3 files, 2 changesets, 4 total revisions |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
90 |
24573
701d3554de0e
manifestv2: add support for writing new manifest format
Martin von Zweigbergk <martinvonz@google.com>
parents:
24571
diff
changeset
|
91 Check that manifest revlog is smaller than for v1 |
24571
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
92 |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
93 $ hg debugindex -m |
919f8ce040be
manifestv2: set requires at repo creation time
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
94 rev offset length base linkrev nodeid p1 p2 |
24573
701d3554de0e
manifestv2: add support for writing new manifest format
Martin von Zweigbergk <martinvonz@google.com>
parents:
24571
diff
changeset
|
95 0 0 81 0 0 57361477c778 000000000000 000000000000 |
701d3554de0e
manifestv2: add support for writing new manifest format
Martin von Zweigbergk <martinvonz@google.com>
parents:
24571
diff
changeset
|
96 1 81 33 0 1 aeaab5a2ef74 57361477c778 000000000000 |