annotate tests/test-issue1306.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 2fc86d92c4a9
children eb586ed5d8ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26420
2fc86d92c4a9 urls: bulk-change BTS urls to new location
Matt Mackall <mpm@selenic.com>
parents: 15615
diff changeset
1 https://bz.mercurial-scm.org/1306
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
2
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
3 Initialize remote repo with branches:
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
4
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
5 $ hg init remote
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
6 $ cd remote
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
7
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
8 $ echo a > a
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
9 $ hg ci -Ama
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
10 adding a
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
11
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
12 $ hg branch br
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
13 marked working directory as branch br
15615
41885892796e branch: warn on branching
Matt Mackall <mpm@selenic.com>
parents: 14162
diff changeset
14 (branches are permanent and global, did you want a bookmark?)
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
15 $ hg ci -Amb
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
16
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
17 $ echo c > c
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
18 $ hg ci -Amc
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
19 adding c
8452
cb93eee1fbcd tests: add missing interpreter lines
Martin Geisler <mg@lazybytes.net>
parents: 7045
diff changeset
20
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
21 $ hg log
14162
301725c3df9a localrepo: reuse parent manifest in commitctx if no files have changed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12847
diff changeset
22 changeset: 2:ae3d9c30ec50
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
23 branch: br
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
24 tag: tip
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
25 user: test
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
26 date: Thu Jan 01 00:00:00 1970 +0000
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
27 summary: c
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
28
14162
301725c3df9a localrepo: reuse parent manifest in commitctx if no files have changed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12847
diff changeset
29 changeset: 1:3f7f930ca414
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
30 branch: br
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
31 user: test
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
32 date: Thu Jan 01 00:00:00 1970 +0000
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
33 summary: b
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
34
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
35 changeset: 0:cb9a9f314b8b
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
36 user: test
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
37 date: Thu Jan 01 00:00:00 1970 +0000
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
38 summary: a
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
39
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
40
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
41 $ cd ..
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
42
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
43 Try cloning -r branch:
7045
f82938c87b92 clone: honor -r even when pulling named branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
44
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
45 $ hg clone -rbr remote local1
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
46 adding changesets
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
47 adding manifests
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
48 adding file changes
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
49 added 3 changesets with 2 changes to 2 files
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
50 updating to branch br
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
51 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
52
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
53 $ hg -R local1 parents
14162
301725c3df9a localrepo: reuse parent manifest in commitctx if no files have changed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12847
diff changeset
54 changeset: 2:ae3d9c30ec50
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
55 branch: br
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
56 tag: tip
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
57 user: test
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
58 date: Thu Jan 01 00:00:00 1970 +0000
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
59 summary: c
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
60
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
61
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
62 Try cloning -rother clone#branch:
7045
f82938c87b92 clone: honor -r even when pulling named branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
63
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
64 $ hg clone -r0 remote#br local2
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
65 adding changesets
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
66 adding manifests
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
67 adding file changes
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
68 added 3 changesets with 2 changes to 2 files
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
69 updating to branch default
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
70 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
71
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
72 $ hg -R local2 parents
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
73 changeset: 0:cb9a9f314b8b
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
74 user: test
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
75 date: Thu Jan 01 00:00:00 1970 +0000
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
76 summary: a
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
77
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
78
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
79 Try cloning -r1 clone#branch:
7045
f82938c87b92 clone: honor -r even when pulling named branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
80
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
81 $ hg clone -r1 remote#br local3
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
82 adding changesets
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
83 adding manifests
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
84 adding file changes
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
85 added 3 changesets with 2 changes to 2 files
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
86 updating to branch br
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
87 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
88
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
89 $ hg -R local3 parents
14162
301725c3df9a localrepo: reuse parent manifest in commitctx if no files have changed
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12847
diff changeset
90 changeset: 1:3f7f930ca414
12195
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
91 branch: br
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
92 user: test
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
93 date: Thu Jan 01 00:00:00 1970 +0000
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
94 summary: b
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
95
ee41be2bbf5a tests: unify test-issue*
Adrian Buehlmann <adrian@cadifra.com>
parents: 8452
diff changeset
96