Mercurial > hg
comparison tests/test-mq-subrepo.t @ 13174:be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
This patch prevents MQ from creating an inconsistent subrepo state. If
the .hgsub file has been changed, and none of the subrepos have
uncommitted changes, creating or updating a patch (using qnew, qrefresh,
or qrecord) will update .hgsubstate accordingly.
If any subrepos _do_ have uncommitted changes, qnew/qrefresh/qrecord
will abort.
Thanks to pmezard for proposing this solution.
author | Kevin Bullock <kbullock@ringworld.org> |
---|---|
date | Tue, 07 Dec 2010 22:14:43 -0600 |
parents | |
children | bb43a9abca80 |
comparison
equal
deleted
inserted
replaced
13173:9b46dd253052 | 13174:be7e8e9bc5e5 |
---|---|
1 $ echo "[extensions]" >> $HGRCPATH | |
2 $ echo "mq=" >> $HGRCPATH | |
3 $ echo "record=" >> $HGRCPATH | |
4 $ echo "[diff]" >> $HGRCPATH | |
5 $ echo "nodates=1" >> $HGRCPATH | |
6 | |
7 fn to create new repository w/dirty subrepo, and cd into it | |
8 $ mkrepo() { | |
9 > hg init $1 | |
10 > cd $1 | |
11 > hg qinit | |
12 > } | |
13 | |
14 fn to create dirty subrepo | |
15 $ mksubrepo() { | |
16 > hg init $1 | |
17 > cd $1 | |
18 > echo a > a | |
19 > hg add | |
20 > cd .. | |
21 > } | |
22 | |
23 $ testadd() { | |
24 > local stdin=`cat` | |
25 > mksubrepo sub | |
26 > echo sub = sub >> .hgsub | |
27 > hg add .hgsub | |
28 > echo % abort when adding .hgsub w/dirty subrepo | |
29 > hg status -S | |
30 > echo '%' $* | |
31 > echo "$stdin" | hg $* | |
32 > echo [$?] | |
33 > hg -R sub ci -m0sub | |
34 > echo % update substate when adding .hgsub w/clean updated subrepo | |
35 > hg status -S | |
36 > echo '%' $* | |
37 > echo "$stdin" | hg $* | |
38 > hg debugsub | |
39 > } | |
40 | |
41 $ testmod() { | |
42 > local stdin=`cat` | |
43 > mksubrepo sub2 | |
44 > echo sub2 = sub2 >> .hgsub | |
45 > echo % abort when modifying .hgsub w/dirty subrepo | |
46 > hg status -S | |
47 > echo '%' $* | |
48 > echo "$stdin" | hg $* | |
49 > echo [$?] | |
50 > hg -R sub2 ci -m0sub2 | |
51 > echo % update substate when modifying .hgsub w/clean updated subrepo | |
52 > hg status -S | |
53 > echo '%' $* | |
54 > echo "$stdin" | hg $* | |
55 > hg debugsub | |
56 > } | |
57 | |
58 $ testrm1() { | |
59 > mksubrepo sub3 | |
60 > echo sub3 = sub3 >> .hgsub | |
61 > hg ci -Aqmsub3 | |
62 > $EXTRA | |
63 > echo b >> sub3/a | |
64 > hg rm .hgsub | |
65 > echo % update substate when removing .hgsub w/dirty subrepo | |
66 > hg status -S | |
67 > echo '%' $* | |
68 > echo "$stdin" | hg $* | |
69 > echo % debugsub should be empty | |
70 > hg debugsub | |
71 > } | |
72 $ testrm2() { | |
73 > mksubrepo sub4 | |
74 > echo sub4 = sub4 >> .hgsub | |
75 > hg ci -Aqmsub4 | |
76 > $EXTRA | |
77 > hg rm .hgsub | |
78 > echo % update substate when removing .hgsub w/clean updated subrepo | |
79 > hg status -S | |
80 > echo '%' $* | |
81 > echo "$stdin" | hg $* | |
82 > echo % debugsub should be empty | |
83 > hg debugsub | |
84 > } | |
85 | |
86 | |
87 handle subrepos safely on qnew | |
88 | |
89 $ mkrepo repo-2499-qnew | |
90 $ testadd qnew -m0 0.diff | |
91 adding a | |
92 % abort when adding .hgsub w/dirty subrepo | |
93 A .hgsub | |
94 A sub/a | |
95 % qnew -m0 0.diff | |
96 abort: uncommitted changes in subrepository sub | |
97 [255] | |
98 % update substate when adding .hgsub w/clean updated subrepo | |
99 A .hgsub | |
100 % qnew -m0 0.diff | |
101 committing subrepository sub | |
102 path sub | |
103 source sub | |
104 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
105 | |
106 $ testmod qnew -m1 1.diff | |
107 adding a | |
108 % abort when modifying .hgsub w/dirty subrepo | |
109 M .hgsub | |
110 A sub2/a | |
111 % qnew -m1 1.diff | |
112 abort: uncommitted changes in subrepository sub2 | |
113 [255] | |
114 % update substate when modifying .hgsub w/clean updated subrepo | |
115 M .hgsub | |
116 % qnew -m1 1.diff | |
117 committing subrepository sub2 | |
118 path sub | |
119 source sub | |
120 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
121 path sub2 | |
122 source sub2 | |
123 revision 1f94c7611cc6b74f5a17b16121a1170d44776845 | |
124 | |
125 $ hg qpop -qa | |
126 patch queue now empty | |
127 $ testrm1 qnew -m2 2.diff | |
128 adding a | |
129 % update substate when removing .hgsub w/dirty subrepo | |
130 M sub3/a | |
131 R .hgsub | |
132 % qnew -m2 2.diff | |
133 % debugsub should be empty | |
134 | |
135 $ hg qpop -qa | |
136 patch queue now empty | |
137 $ testrm2 qnew -m3 3.diff | |
138 adding a | |
139 % update substate when removing .hgsub w/clean updated subrepo | |
140 R .hgsub | |
141 % qnew -m3 3.diff | |
142 % debugsub should be empty | |
143 | |
144 $ cd .. | |
145 | |
146 | |
147 handle subrepos safely on qrefresh | |
148 | |
149 $ mkrepo repo-2499-qrefresh | |
150 $ hg qnew -m0 0.diff | |
151 $ testadd qrefresh | |
152 adding a | |
153 % abort when adding .hgsub w/dirty subrepo | |
154 A .hgsub | |
155 A sub/a | |
156 % qrefresh | |
157 abort: uncommitted changes in subrepository sub | |
158 [255] | |
159 % update substate when adding .hgsub w/clean updated subrepo | |
160 A .hgsub | |
161 % qrefresh | |
162 committing subrepository sub | |
163 path sub | |
164 source sub | |
165 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
166 | |
167 $ hg qnew -m1 1.diff | |
168 $ testmod qrefresh | |
169 adding a | |
170 % abort when modifying .hgsub w/dirty subrepo | |
171 M .hgsub | |
172 A sub2/a | |
173 % qrefresh | |
174 abort: uncommitted changes in subrepository sub2 | |
175 [255] | |
176 % update substate when modifying .hgsub w/clean updated subrepo | |
177 M .hgsub | |
178 % qrefresh | |
179 committing subrepository sub2 | |
180 path sub | |
181 source sub | |
182 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
183 path sub2 | |
184 source sub2 | |
185 revision 1f94c7611cc6b74f5a17b16121a1170d44776845 | |
186 | |
187 $ hg qpop -qa | |
188 patch queue now empty | |
189 $ EXTRA='hg qnew -m2 2.diff' testrm1 qrefresh | |
190 adding a | |
191 % update substate when removing .hgsub w/dirty subrepo | |
192 M sub3/a | |
193 R .hgsub | |
194 % qrefresh | |
195 % debugsub should be empty | |
196 | |
197 $ hg qpop -qa | |
198 patch queue now empty | |
199 $ EXTRA='hg qnew -m3 3.diff' testrm2 qrefresh | |
200 adding a | |
201 % update substate when removing .hgsub w/clean updated subrepo | |
202 R .hgsub | |
203 % qrefresh | |
204 % debugsub should be empty | |
205 | |
206 $ cd .. | |
207 | |
208 | |
209 handle subrepos safely on qpush/qpop | |
210 | |
211 $ mkrepo repo-2499-qpush | |
212 $ mksubrepo sub | |
213 adding a | |
214 $ hg -R sub ci -m0sub | |
215 $ echo sub = sub > .hgsub | |
216 $ hg add .hgsub | |
217 $ hg qnew -m0 0.diff | |
218 committing subrepository sub | |
219 $ hg debugsub | |
220 path sub | |
221 source sub | |
222 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
223 | |
224 qpop | |
225 $ hg qpop | |
226 popping 0.diff | |
227 patch queue now empty | |
228 $ hg status -AS | |
229 $ hg debugsub | |
230 | |
231 qpush | |
232 $ hg qpush | |
233 applying 0.diff | |
234 now at: 0.diff | |
235 $ hg status -AS | |
236 C .hgsub | |
237 C .hgsubstate | |
238 C sub/a | |
239 $ hg debugsub | |
240 path sub | |
241 source sub | |
242 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
243 | |
244 $ cd .. | |
245 | |
246 | |
247 handle subrepos safely on qrecord | |
248 | |
249 $ mkrepo repo-2499-qrecord | |
250 $ testadd qrecord --config ui.interactive=1 -m0 0.diff <<EOF | |
251 > y | |
252 > y | |
253 > EOF | |
254 adding a | |
255 % abort when adding .hgsub w/dirty subrepo | |
256 A .hgsub | |
257 A sub/a | |
258 % qrecord --config ui.interactive=1 -m0 0.diff | |
259 diff --git a/.hgsub b/.hgsub | |
260 new file mode 100644 | |
261 examine changes to '.hgsub'? [Ynsfdaq?] | |
262 abort: uncommitted changes in subrepository sub | |
263 [255] | |
264 % update substate when adding .hgsub w/clean updated subrepo | |
265 A .hgsub | |
266 % qrecord --config ui.interactive=1 -m0 0.diff | |
267 diff --git a/.hgsub b/.hgsub | |
268 new file mode 100644 | |
269 examine changes to '.hgsub'? [Ynsfdaq?] | |
270 committing subrepository sub | |
271 path sub | |
272 source sub | |
273 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
274 | |
275 $ testmod qrecord --config ui.interactive=1 -m1 1.diff <<EOF | |
276 > y | |
277 > y | |
278 > EOF | |
279 adding a | |
280 % abort when modifying .hgsub w/dirty subrepo | |
281 M .hgsub | |
282 A sub2/a | |
283 % qrecord --config ui.interactive=1 -m1 1.diff | |
284 diff --git a/.hgsub b/.hgsub | |
285 1 hunks, 1 lines changed | |
286 examine changes to '.hgsub'? [Ynsfdaq?] | |
287 @@ -1,1 +1,2 @@ | |
288 sub = sub | |
289 +sub2 = sub2 | |
290 record this change to '.hgsub'? [Ynsfdaq?] | |
291 abort: uncommitted changes in subrepository sub2 | |
292 [255] | |
293 % update substate when modifying .hgsub w/clean updated subrepo | |
294 M .hgsub | |
295 % qrecord --config ui.interactive=1 -m1 1.diff | |
296 diff --git a/.hgsub b/.hgsub | |
297 1 hunks, 1 lines changed | |
298 examine changes to '.hgsub'? [Ynsfdaq?] | |
299 @@ -1,1 +1,2 @@ | |
300 sub = sub | |
301 +sub2 = sub2 | |
302 record this change to '.hgsub'? [Ynsfdaq?] | |
303 committing subrepository sub2 | |
304 path sub | |
305 source sub | |
306 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31 | |
307 path sub2 | |
308 source sub2 | |
309 revision 1f94c7611cc6b74f5a17b16121a1170d44776845 | |
310 | |
311 $ hg qpop -qa | |
312 patch queue now empty | |
313 $ EXTRA= testrm1 qrecord --config ui.interactive=1 -m2 2.diff <<EOF | |
314 > y | |
315 > y | |
316 > EOF | |
317 adding a | |
318 % update substate when removing .hgsub w/dirty subrepo | |
319 M sub3/a | |
320 R .hgsub | |
321 % qrecord --config ui.interactive=1 -m2 2.diff | |
322 diff --git a/.hgsub b/.hgsub | |
323 deleted file mode 100644 | |
324 examine changes to '.hgsub'? [Ynsfdaq?] | |
325 % debugsub should be empty | |
326 | |
327 $ hg qpop -qa | |
328 patch queue now empty | |
329 $ EXTRA= testrm2 qrecord --config ui.interactive=1 -m3 3.diff <<EOF | |
330 > y | |
331 > y | |
332 > EOF | |
333 adding a | |
334 % update substate when removing .hgsub w/clean updated subrepo | |
335 R .hgsub | |
336 % qrecord --config ui.interactive=1 -m3 3.diff | |
337 diff --git a/.hgsub b/.hgsub | |
338 deleted file mode 100644 | |
339 examine changes to '.hgsub'? [Ynsfdaq?] | |
340 % debugsub should be empty | |
341 | |
342 $ cd .. |