##// END OF EJS Templates
transaction: tests we don't overwrite branch changes on abort...
marmoute -
r51066:d956ceed stable
parent child Browse files
Show More
@@ -1,157 +1,190
1 =======================================================================
1 =======================================================================
2 Check potential race condition around transaction and working copy data
2 Check potential race condition around transaction and working copy data
3 =======================================================================
3 =======================================================================
4
4
5 #testcases bookmarks-in-store bookmarks-wc-level
5 #testcases bookmarks-in-store bookmarks-wc-level
6
6
7 The transaction is garanteed to run with the lock, but may runs without the
7 The transaction is garanteed to run with the lock, but may runs without the
8 wlock. So if the transaction backup/restore some content related to the
8 wlock. So if the transaction backup/restore some content related to the
9 working-copy and protected by the wlock, we might run into trouble if another
9 working-copy and protected by the wlock, we might run into trouble if another
10 process grab the wlock and modify them.
10 process grab the wlock and modify them.
11
11
12 This test file is testing various cases where such parallel changes happens to
12 This test file is testing various cases where such parallel changes happens to
13 validate the transaction behavior.
13 validate the transaction behavior.
14
14
15 Other is used to get a simple pull source. As pull is a simple way to create
15 Other is used to get a simple pull source. As pull is a simple way to create
16 transaction without the wlock.
16 transaction without the wlock.
17
17
18 Setup
18 Setup
19 =====
19 =====
20
20
21 Avoid long deadlock
21 Avoid long deadlock
22
22
23 $ cat << EOF >> $HGRCPATH
23 $ cat << EOF >> $HGRCPATH
24 > [ui]
24 > [ui]
25 > timeout=10
25 > timeout=10
26 > EOF
26 > EOF
27
27
28 #if bookmarks-in-store
28 #if bookmarks-in-store
29 $ cat << EOF >> $HGRCPATH
29 $ cat << EOF >> $HGRCPATH
30 > [format]
30 > [format]
31 > bookmarks-in-store = yes
31 > bookmarks-in-store = yes
32 > EOF
32 > EOF
33 #endif
33 #endif
34
34
35
35
36 $ hg init repo
36 $ hg init repo
37 $ cd repo
37 $ cd repo
38 $ for filename in a b c d e f g h i j k l m; do
38 $ for filename in a b c d e f g h i j k l m; do
39 > echo $filename > default_$filename
39 > echo $filename > default_$filename
40 > hg add default_$filename
40 > hg add default_$filename
41 > hg commit --quiet --message default_$filename
41 > hg commit --quiet --message default_$filename
42 > done
42 > done
43 $ hg bookmark --rev . foo
43 $ hg bookmark --rev . foo
44 $ hg branch babar
44 $ hg branch babar
45 marked working directory as branch babar
45 marked working directory as branch babar
46 (branches are permanent and global, did you want a bookmark?)
46 (branches are permanent and global, did you want a bookmark?)
47 $ for filename in a b c d e f g h i j k l m; do
47 $ for filename in a b c d e f g h i j k l m; do
48 > echo $filename > babar_$filename
48 > echo $filename > babar_$filename
49 > hg add babar_$filename
49 > hg add babar_$filename
50 > hg commit --quiet --message babar_$filename
50 > hg commit --quiet --message babar_$filename
51 > done
51 > done
52 $ hg bookmark --rev . bar
52 $ hg bookmark --rev . bar
53 $ hg up 'desc("default_m")'
53 $ hg up 'desc("default_m")'
54 0 files updated, 0 files merged, 13 files removed, 0 files unresolved
54 0 files updated, 0 files merged, 13 files removed, 0 files unresolved
55 $ hg log -G -T '[{branch}] ({bookmarks}) {desc}\n'
55 $ hg log -G -T '[{branch}] ({bookmarks}) {desc}\n'
56 o [babar] (bar) babar_m
56 o [babar] (bar) babar_m
57 |
57 |
58 o [babar] () babar_l
58 o [babar] () babar_l
59 |
59 |
60 o [babar] () babar_k
60 o [babar] () babar_k
61 |
61 |
62 o [babar] () babar_j
62 o [babar] () babar_j
63 |
63 |
64 o [babar] () babar_i
64 o [babar] () babar_i
65 |
65 |
66 o [babar] () babar_h
66 o [babar] () babar_h
67 |
67 |
68 o [babar] () babar_g
68 o [babar] () babar_g
69 |
69 |
70 o [babar] () babar_f
70 o [babar] () babar_f
71 |
71 |
72 o [babar] () babar_e
72 o [babar] () babar_e
73 |
73 |
74 o [babar] () babar_d
74 o [babar] () babar_d
75 |
75 |
76 o [babar] () babar_c
76 o [babar] () babar_c
77 |
77 |
78 o [babar] () babar_b
78 o [babar] () babar_b
79 |
79 |
80 o [babar] () babar_a
80 o [babar] () babar_a
81 |
81 |
82 @ [default] (foo) default_m
82 @ [default] (foo) default_m
83 |
83 |
84 o [default] () default_l
84 o [default] () default_l
85 |
85 |
86 o [default] () default_k
86 o [default] () default_k
87 |
87 |
88 o [default] () default_j
88 o [default] () default_j
89 |
89 |
90 o [default] () default_i
90 o [default] () default_i
91 |
91 |
92 o [default] () default_h
92 o [default] () default_h
93 |
93 |
94 o [default] () default_g
94 o [default] () default_g
95 |
95 |
96 o [default] () default_f
96 o [default] () default_f
97 |
97 |
98 o [default] () default_e
98 o [default] () default_e
99 |
99 |
100 o [default] () default_d
100 o [default] () default_d
101 |
101 |
102 o [default] () default_c
102 o [default] () default_c
103 |
103 |
104 o [default] () default_b
104 o [default] () default_b
105 |
105 |
106 o [default] () default_a
106 o [default] () default_a
107
107
108
108
109 $ cat << EOF >> ../txn-close.sh
109 $ cat << EOF >> ../txn-close.sh
110 > rm -f $TESTTMP/transaction-continue
110 > rm -f $TESTTMP/transaction-continue
111 > $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-continue $TESTTMP/transaction-waiting
111 > $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-continue $TESTTMP/transaction-waiting
112 > rm -f $TESTTMP/transaction-waiting
112 > rm -f $TESTTMP/transaction-waiting
113 > exit 1
113 > exit 1
114 > EOF
114 > EOF
115 $ cat << EOF >> .hg/hgrc
115 $ cat << EOF >> .hg/hgrc
116 > [hooks]
116 > [hooks]
117 > pretxnclose.test = sh $TESTTMP/txn-close.sh
117 > pretxnclose.test = sh $TESTTMP/txn-close.sh
118 > EOF
118 > EOF
119
119
120 Check the overall logic is working, the transaction is holding the `lock` , but
120 Check the overall logic is working, the transaction is holding the `lock` , but
121 not the `wlock`, then get aborted on a signal-file.
121 not the `wlock`, then get aborted on a signal-file.
122
122
123 $ hg phase --rev 0
123 $ hg phase --rev 0
124 0: draft
124 0: draft
125 $ hg phase --public --rev 0 2> ../log.err &
125 $ hg phase --public --rev 0 2> ../log.err &
126 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting
126 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting
127 $ echo y | hg --config ui.interactive=yes debuglock --set-wlock
127 $ echo y | hg --config ui.interactive=yes debuglock --set-wlock
128 ready to release the lock (y)? y
128 ready to release the lock (y)? y
129 $ echo y | hg --config ui.interactive=yes debuglock --set-lock
129 $ echo y | hg --config ui.interactive=yes debuglock --set-lock
130 abort: lock is already held
130 abort: lock is already held
131 [255]
131 [255]
132 $ touch $TESTTMP/transaction-continue
132 $ touch $TESTTMP/transaction-continue
133 $ wait
133 $ wait
134 $ hg phase --rev 0
134 $ hg phase --rev 0
135 0: draft
135 0: draft
136 $ cat ../log.err
136 $ cat ../log.err
137 transaction abort!
137 transaction abort!
138 rollback completed
138 rollback completed
139 abort: pretxnclose.test hook exited with status 1
139 abort: pretxnclose.test hook exited with status 1
140
140
141 Actual testing
141 Actual testing
142 ==============
142 ==============
143
143
144 Changing tracked file
144 Changing tracked file
145 ---------------------
145 ---------------------
146
146
147 $ hg status
147 $ hg status
148 $ hg phase --public --rev 0 2> ../log.err &
148 $ hg phase --public --rev 0 2> ../log.err &
149 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting
149 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting
150 $ hg forget default_a
150 $ hg forget default_a
151 $ hg status
151 $ hg status
152 R default_a
152 R default_a
153 $ touch $TESTTMP/transaction-continue
153 $ touch $TESTTMP/transaction-continue
154 $ wait
154 $ wait
155 $ hg status
155 $ hg status
156 R default_a (missing-correct-output !)
156 R default_a (missing-correct-output !)
157 $ hg revert --all --quiet
157 $ hg revert --all --quiet
158
159 Changing branch from default
160 ----------------------------
161
162 $ hg branch
163 default
164 $ hg phase --public --rev 0 2> ../log.err &
165 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting
166 $ hg branch celeste
167 marked working directory as branch celeste
168 $ hg branch
169 celeste
170 $ touch $TESTTMP/transaction-continue
171 $ wait
172 $ hg branch
173 celeste
174
175 Changing branch from another one
176 --------------------------------
177
178 $ hg up babar --quiet
179 $ hg branch
180 babar
181 $ hg phase --public --rev 0 2> ../log.err &
182 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting
183 $ hg branch celeste
184 marked working directory as branch celeste
185 $ hg branch
186 celeste
187 $ touch $TESTTMP/transaction-continue
188 $ wait
189 $ hg branch
190 celeste
General Comments 0
You need to be logged in to leave comments. Login now