Show More
@@ -1,212 +1,485 b'' | |||
|
1 | 1 | setup repo |
|
2 | 2 | $ hg init t |
|
3 | 3 | $ cd t |
|
4 | 4 | $ echo a > a |
|
5 | 5 | $ hg commit -Am'add a' |
|
6 | 6 | adding a |
|
7 | 7 | $ hg verify |
|
8 | 8 | checking changesets |
|
9 | 9 | checking manifests |
|
10 | 10 | crosschecking files in changesets and manifests |
|
11 | 11 | checking files |
|
12 | 12 | 1 files, 1 changesets, 1 total revisions |
|
13 | 13 | $ hg parents |
|
14 | 14 | changeset: 0:1f0dee641bb7 |
|
15 | 15 | tag: tip |
|
16 | 16 | user: test |
|
17 | 17 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
18 | 18 | summary: add a |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | rollback to null revision |
|
22 | 22 | $ hg status |
|
23 | 23 | $ hg rollback |
|
24 | 24 | repository tip rolled back to revision -1 (undo commit) |
|
25 | 25 | working directory now based on revision -1 |
|
26 | 26 | $ hg verify |
|
27 | 27 | checking changesets |
|
28 | 28 | checking manifests |
|
29 | 29 | crosschecking files in changesets and manifests |
|
30 | 30 | checking files |
|
31 | 31 | 0 files, 0 changesets, 0 total revisions |
|
32 | 32 | $ hg parents |
|
33 | 33 | $ hg status |
|
34 | 34 | A a |
|
35 | 35 | |
|
36 | 36 | Two changesets this time so we rollback to a real changeset |
|
37 | 37 | $ hg commit -m'add a again' |
|
38 | 38 | $ echo a >> a |
|
39 | 39 | $ hg commit -m'modify a' |
|
40 | 40 | |
|
41 | 41 | Test issue 902 (current branch is preserved) |
|
42 | 42 | $ hg branch test |
|
43 | 43 | marked working directory as branch test |
|
44 | 44 | (branches are permanent and global, did you want a bookmark?) |
|
45 | 45 | $ hg rollback |
|
46 | 46 | repository tip rolled back to revision 0 (undo commit) |
|
47 | 47 | working directory now based on revision 0 |
|
48 | 48 | $ hg branch |
|
49 | 49 | default |
|
50 | 50 | |
|
51 | 51 | Test issue 1635 (commit message saved) |
|
52 | 52 | $ cat .hg/last-message.txt ; echo |
|
53 | 53 | modify a |
|
54 | 54 | |
|
55 | 55 | Test rollback of hg before issue 902 was fixed |
|
56 | 56 | |
|
57 | 57 | $ hg commit -m "test3" |
|
58 | 58 | $ hg branch test |
|
59 | 59 | marked working directory as branch test |
|
60 | 60 | (branches are permanent and global, did you want a bookmark?) |
|
61 | 61 | $ rm .hg/undo.branch |
|
62 | 62 | $ hg rollback |
|
63 | 63 | repository tip rolled back to revision 0 (undo commit) |
|
64 | 64 | named branch could not be reset: current branch is still 'test' |
|
65 | 65 | working directory now based on revision 0 |
|
66 | 66 | $ hg branch |
|
67 | 67 | test |
|
68 | 68 | |
|
69 | 69 | working dir unaffected by rollback: do not restore dirstate et. al. |
|
70 | 70 | $ hg log --template '{rev} {branch} {desc|firstline}\n' |
|
71 | 71 | 0 default add a again |
|
72 | 72 | $ hg status |
|
73 | 73 | M a |
|
74 | 74 | $ hg bookmark foo |
|
75 | 75 | $ hg commit -m'modify a again' |
|
76 | 76 | $ echo b > b |
|
77 | 77 | $ hg bookmark bar -r default #making bar active, before the transaction |
|
78 | 78 | $ hg commit -Am'add b' |
|
79 | 79 | adding b |
|
80 | 80 | $ hg log --template '{rev} {branch} {desc|firstline}\n' |
|
81 | 81 | 2 test add b |
|
82 | 82 | 1 test modify a again |
|
83 | 83 | 0 default add a again |
|
84 | 84 | $ hg update bar |
|
85 | 85 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
86 | 86 | (activating bookmark bar) |
|
87 | 87 | $ cat .hg/undo.branch ; echo |
|
88 | 88 | test |
|
89 | 89 | $ hg rollback -f |
|
90 | 90 | repository tip rolled back to revision 1 (undo commit) |
|
91 | 91 | $ hg id -n |
|
92 | 92 | 0 |
|
93 | 93 | $ hg branch |
|
94 | 94 | default |
|
95 | 95 | $ cat .hg/bookmarks.current ; echo |
|
96 | 96 | bar |
|
97 | 97 | $ hg bookmark --delete foo bar |
|
98 | 98 | |
|
99 | 99 | rollback by pretxncommit saves commit message (issue1635) |
|
100 | 100 | |
|
101 | 101 | $ echo a >> a |
|
102 | 102 | $ hg --config hooks.pretxncommit=false commit -m"precious commit message" |
|
103 | 103 | transaction abort! |
|
104 | 104 | rollback completed |
|
105 | 105 | abort: pretxncommit hook exited with status * (glob) |
|
106 | 106 | [255] |
|
107 | 107 | $ cat .hg/last-message.txt ; echo |
|
108 | 108 | precious commit message |
|
109 | 109 | |
|
110 | 110 | same thing, but run $EDITOR |
|
111 | 111 | |
|
112 | 112 | $ cat > editor.sh << '__EOF__' |
|
113 | 113 | > echo "another precious commit message" > "$1" |
|
114 | 114 | > __EOF__ |
|
115 | 115 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg --config hooks.pretxncommit=false commit 2>&1 |
|
116 | 116 | note: commit message saved in .hg/last-message.txt |
|
117 | 117 | transaction abort! |
|
118 | 118 | rollback completed |
|
119 | 119 | abort: pretxncommit hook exited with status * (glob) |
|
120 | 120 | [255] |
|
121 | 121 | $ cat .hg/last-message.txt |
|
122 | 122 | another precious commit message |
|
123 | 123 | |
|
124 | 124 | test rollback on served repository |
|
125 | 125 | |
|
126 | 126 | #if serve |
|
127 | 127 | $ hg commit -m "precious commit message" |
|
128 | 128 | $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log |
|
129 | 129 | $ cat hg.pid >> $DAEMON_PIDS |
|
130 | 130 | $ cd .. |
|
131 | 131 | $ hg clone http://localhost:$HGPORT u |
|
132 | 132 | requesting all changes |
|
133 | 133 | adding changesets |
|
134 | 134 | adding manifests |
|
135 | 135 | adding file changes |
|
136 | 136 | added 3 changesets with 2 changes to 1 files (+1 heads) |
|
137 | 137 | updating to branch default |
|
138 | 138 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
139 | 139 | $ cd u |
|
140 | 140 | $ hg id default |
|
141 | 141 | 068774709090 |
|
142 | 142 | |
|
143 | 143 | now rollback and observe that 'hg serve' reloads the repository and |
|
144 | 144 | presents the correct tip changeset: |
|
145 | 145 | |
|
146 | 146 | $ hg -R ../t rollback |
|
147 | 147 | repository tip rolled back to revision 1 (undo commit) |
|
148 | 148 | working directory now based on revision 0 |
|
149 | 149 | $ hg id default |
|
150 | 150 | 791dd2169706 |
|
151 | 151 | |
|
152 | 152 | $ killdaemons.py |
|
153 | 153 | #endif |
|
154 | 154 | |
|
155 | 155 | update to older changeset and then refuse rollback, because |
|
156 | 156 | that would lose data (issue2998) |
|
157 | 157 | $ cd ../t |
|
158 | 158 | $ hg -q update |
|
159 | 159 | $ rm `hg status -un` |
|
160 | 160 | $ template='{rev}:{node|short} [{branch}] {desc|firstline}\n' |
|
161 | 161 | $ echo 'valuable new file' > b |
|
162 | 162 | $ echo 'valuable modification' >> a |
|
163 | 163 | $ hg commit -A -m'a valuable change' |
|
164 | 164 | adding b |
|
165 | 165 | $ hg update 0 |
|
166 | 166 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
167 | 167 | $ hg rollback |
|
168 | 168 | abort: rollback of last commit while not checked out may lose data |
|
169 | 169 | (use -f to force) |
|
170 | 170 | [255] |
|
171 | 171 | $ hg tip -q |
|
172 | 172 | 2:4d9cd3795eea |
|
173 | 173 | $ hg rollback -f |
|
174 | 174 | repository tip rolled back to revision 1 (undo commit) |
|
175 | 175 | $ hg status |
|
176 | 176 | $ hg log --removed b # yep, it's gone |
|
177 | 177 | |
|
178 | 178 | same again, but emulate an old client that doesn't write undo.desc |
|
179 | 179 | $ hg -q update |
|
180 | 180 | $ echo 'valuable modification redux' >> a |
|
181 | 181 | $ hg commit -m'a valuable change redux' |
|
182 | 182 | $ rm .hg/undo.desc |
|
183 | 183 | $ hg update 0 |
|
184 | 184 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
185 | 185 | $ hg rollback |
|
186 | 186 | rolling back unknown transaction |
|
187 | 187 | $ cat a |
|
188 | 188 | a |
|
189 | 189 | |
|
190 | 190 | corrupt journal test |
|
191 | 191 | $ echo "foo" > .hg/store/journal |
|
192 | 192 | $ hg recover |
|
193 | 193 | rolling back interrupted transaction |
|
194 | 194 | couldn't read journal entry 'foo\n'! |
|
195 | 195 | checking changesets |
|
196 | 196 | checking manifests |
|
197 | 197 | crosschecking files in changesets and manifests |
|
198 | 198 | checking files |
|
199 | 199 | 1 files, 2 changesets, 2 total revisions |
|
200 | 200 | |
|
201 | 201 | rollback disabled by config |
|
202 | 202 | $ cat >> $HGRCPATH <<EOF |
|
203 | 203 | > [ui] |
|
204 | 204 | > rollback = false |
|
205 | 205 | > EOF |
|
206 | 206 | $ echo narf >> pinky-sayings.txt |
|
207 | 207 | $ hg add pinky-sayings.txt |
|
208 | 208 | $ hg ci -m 'First one.' |
|
209 | 209 | $ hg rollback |
|
210 | 210 | abort: rollback is disabled because it is unsafe |
|
211 | 211 | (see `hg help -v rollback` for information) |
|
212 | 212 | [255] |
|
213 | ||
|
214 | $ cd .. | |
|
215 | ||
|
216 | I/O errors on stdio are handled properly (issue5658) | |
|
217 | ||
|
218 | $ cat > badui.py << EOF | |
|
219 | > import errno | |
|
220 | > from mercurial.i18n import _ | |
|
221 | > from mercurial import ( | |
|
222 | > error, | |
|
223 | > ui as uimod, | |
|
224 | > ) | |
|
225 | > | |
|
226 | > def pretxncommit(ui, repo, **kwargs): | |
|
227 | > ui.warn('warn during pretxncommit\n') | |
|
228 | > | |
|
229 | > def pretxnclose(ui, repo, **kwargs): | |
|
230 | > ui.warn('warn during pretxnclose\n') | |
|
231 | > | |
|
232 | > def txnclose(ui, repo, **kwargs): | |
|
233 | > ui.warn('warn during txnclose\n') | |
|
234 | > | |
|
235 | > def txnabort(ui, repo, **kwargs): | |
|
236 | > ui.warn('warn during abort\n') | |
|
237 | > | |
|
238 | > class fdproxy(object): | |
|
239 | > def __init__(self, ui, o): | |
|
240 | > self._ui = ui | |
|
241 | > self._o = o | |
|
242 | > | |
|
243 | > def __getattr__(self, attr): | |
|
244 | > return getattr(self._o, attr) | |
|
245 | > | |
|
246 | > def write(self, msg): | |
|
247 | > errors = set(self._ui.configlist('ui', 'ioerrors', [])) | |
|
248 | > pretxncommit = msg == 'warn during pretxncommit\n' | |
|
249 | > pretxnclose = msg == 'warn during pretxnclose\n' | |
|
250 | > txnclose = msg == 'warn during txnclose\n' | |
|
251 | > txnabort = msg == 'warn during abort\n' | |
|
252 | > msgabort = msg == _('transaction abort!\n') | |
|
253 | > msgrollback = msg == _('rollback completed\n') | |
|
254 | > | |
|
255 | > if pretxncommit and 'pretxncommit' in errors: | |
|
256 | > raise IOError(errno.EPIPE, 'simulated epipe') | |
|
257 | > if pretxnclose and 'pretxnclose' in errors: | |
|
258 | > raise IOError(errno.EIO, 'simulated eio') | |
|
259 | > if txnclose and 'txnclose' in errors: | |
|
260 | > raise IOError(errno.EBADF, 'simulated badf') | |
|
261 | > if txnabort and 'txnabort' in errors: | |
|
262 | > raise IOError(errno.EPIPE, 'simulated epipe') | |
|
263 | > if msgabort and 'msgabort' in errors: | |
|
264 | > raise IOError(errno.EBADF, 'simulated ebadf') | |
|
265 | > if msgrollback and 'msgrollback' in errors: | |
|
266 | > raise IOError(errno.EIO, 'simulated eio') | |
|
267 | > | |
|
268 | > return self._o.write(msg) | |
|
269 | > | |
|
270 | > def uisetup(ui): | |
|
271 | > class badui(ui.__class__): | |
|
272 | > def write_err(self, *args, **kwargs): | |
|
273 | > olderr = self.ferr | |
|
274 | > try: | |
|
275 | > self.ferr = fdproxy(self, olderr) | |
|
276 | > return super(badui, self).write_err(*args, **kwargs) | |
|
277 | > finally: | |
|
278 | > self.ferr = olderr | |
|
279 | > | |
|
280 | > ui.__class__ = badui | |
|
281 | > | |
|
282 | > def reposetup(ui, repo): | |
|
283 | > ui.setconfig('hooks', 'pretxnclose.badui', pretxnclose, 'badui') | |
|
284 | > ui.setconfig('hooks', 'txnclose.badui', txnclose, 'badui') | |
|
285 | > ui.setconfig('hooks', 'pretxncommit.badui', pretxncommit, 'badui') | |
|
286 | > ui.setconfig('hooks', 'txnabort.badui', txnabort, 'badui') | |
|
287 | > EOF | |
|
288 | ||
|
289 | $ cat >> $HGRCPATH << EOF | |
|
290 | > [extensions] | |
|
291 | > badui = $TESTTMP/badui.py | |
|
292 | > EOF | |
|
293 | ||
|
294 | An I/O error during pretxncommit is handled | |
|
295 | ||
|
296 | $ hg init ioerror-pretxncommit | |
|
297 | $ cd ioerror-pretxncommit | |
|
298 | $ echo 0 > foo | |
|
299 | $ hg -q commit -A -m initial | |
|
300 | warn during pretxncommit | |
|
301 | warn during pretxnclose | |
|
302 | warn during txnclose | |
|
303 | $ echo 1 > foo | |
|
304 | $ hg --config ui.ioerrors=pretxncommit commit -m 'error during pretxncommit' | |
|
305 | error: pretxncommit.badui hook raised an exception: [Errno *] simulated epipe (glob) | |
|
306 | transaction abort! | |
|
307 | warn during abort | |
|
308 | rollback completed | |
|
309 | [255] | |
|
310 | ||
|
311 | $ hg commit -m 'commit 1' | |
|
312 | warn during pretxncommit | |
|
313 | warn during pretxnclose | |
|
314 | warn during txnclose | |
|
315 | ||
|
316 | $ cd .. | |
|
317 | ||
|
318 | An I/O error during pretxnclose is handled | |
|
319 | ||
|
320 | $ hg init ioerror-pretxnclose | |
|
321 | $ cd ioerror-pretxnclose | |
|
322 | $ echo 0 > foo | |
|
323 | $ hg -q commit -A -m initial | |
|
324 | warn during pretxncommit | |
|
325 | warn during pretxnclose | |
|
326 | warn during txnclose | |
|
327 | ||
|
328 | $ echo 1 > foo | |
|
329 | $ hg --config ui.ioerrors=pretxnclose commit -m 'error during pretxnclose' | |
|
330 | warn during pretxncommit | |
|
331 | error: pretxnclose.badui hook raised an exception: [Errno *] simulated eio (glob) | |
|
332 | transaction abort! | |
|
333 | warn during abort | |
|
334 | rollback completed | |
|
335 | abort: simulated eio | |
|
336 | [255] | |
|
337 | ||
|
338 | $ hg commit -m 'commit 1' | |
|
339 | warn during pretxncommit | |
|
340 | warn during pretxnclose | |
|
341 | warn during txnclose | |
|
342 | ||
|
343 | $ cd .. | |
|
344 | ||
|
345 | An I/O error during txnclose is handled | |
|
346 | ||
|
347 | $ hg init ioerror-txnclose | |
|
348 | $ cd ioerror-txnclose | |
|
349 | $ echo 0 > foo | |
|
350 | $ hg -q commit -A -m initial | |
|
351 | warn during pretxncommit | |
|
352 | warn during pretxnclose | |
|
353 | warn during txnclose | |
|
354 | ||
|
355 | $ echo 1 > foo | |
|
356 | $ hg --config ui.ioerrors=txnclose commit -m 'error during txnclose' | |
|
357 | warn during pretxncommit | |
|
358 | warn during pretxnclose | |
|
359 | error: txnclose.badui hook raised an exception: [Errno *] simulated badf (glob) | |
|
360 | (run with --traceback for stack trace) | |
|
361 | ||
|
362 | $ hg commit -m 'commit 1' | |
|
363 | nothing changed | |
|
364 | [1] | |
|
365 | ||
|
366 | $ cd .. | |
|
367 | ||
|
368 | An I/O error writing "transaction abort" is handled | |
|
369 | ||
|
370 | $ hg init ioerror-msgabort | |
|
371 | $ cd ioerror-msgabort | |
|
372 | ||
|
373 | $ echo 0 > foo | |
|
374 | $ hg -q commit -A -m initial | |
|
375 | warn during pretxncommit | |
|
376 | warn during pretxnclose | |
|
377 | warn during txnclose | |
|
378 | ||
|
379 | $ echo 1 > foo | |
|
380 | $ hg --config ui.ioerrors=msgabort --config hooks.pretxncommit=false commit -m 'error during abort message' | |
|
381 | abort: simulated ebadf | |
|
382 | *: DeprecationWarning: use lock.release instead of del lock (glob) | |
|
383 | return -1 | |
|
384 | [255] | |
|
385 | ||
|
386 | $ hg commit -m 'commit 1' | |
|
387 | abort: abandoned transaction found! | |
|
388 | (run 'hg recover' to clean up transaction) | |
|
389 | [255] | |
|
390 | ||
|
391 | $ cd .. | |
|
392 | ||
|
393 | An I/O error during txnabort should still result in rollback | |
|
394 | ||
|
395 | $ hg init ioerror-txnabort | |
|
396 | $ cd ioerror-txnabort | |
|
397 | ||
|
398 | $ echo 0 > foo | |
|
399 | $ hg -q commit -A -m initial | |
|
400 | warn during pretxncommit | |
|
401 | warn during pretxnclose | |
|
402 | warn during txnclose | |
|
403 | ||
|
404 | $ echo 1 > foo | |
|
405 | $ hg --config ui.ioerrors=txnabort --config hooks.pretxncommit=false commit -m 'error during abort' | |
|
406 | transaction abort! | |
|
407 | error: txnabort.badui hook raised an exception: [Errno *] simulated epipe (glob) | |
|
408 | (run with --traceback for stack trace) | |
|
409 | rollback completed | |
|
410 | abort: pretxncommit hook exited with status 1 | |
|
411 | [255] | |
|
412 | ||
|
413 | $ hg commit -m 'commit 1' | |
|
414 | warn during pretxncommit | |
|
415 | warn during pretxnclose | |
|
416 | warn during txnclose | |
|
417 | ||
|
418 | $ cd .. | |
|
419 | ||
|
420 | An I/O error writing "rollback completed" is handled | |
|
421 | ||
|
422 | $ hg init ioerror-msgrollback | |
|
423 | $ cd ioerror-msgrollback | |
|
424 | ||
|
425 | $ echo 0 > foo | |
|
426 | $ hg -q commit -A -m initial | |
|
427 | warn during pretxncommit | |
|
428 | warn during pretxnclose | |
|
429 | warn during txnclose | |
|
430 | ||
|
431 | $ echo 1 > foo | |
|
432 | ||
|
433 | $ hg --config ui.ioerrors=msgrollback --config hooks.pretxncommit=false commit -m 'error during rollback message' | |
|
434 | transaction abort! | |
|
435 | warn during abort | |
|
436 | rollback failed - please run hg recover | |
|
437 | abort: pretxncommit hook exited with status 1 | |
|
438 | [255] | |
|
439 | ||
|
440 | $ hg verify | |
|
441 | checking changesets | |
|
442 | checking manifests | |
|
443 | crosschecking files in changesets and manifests | |
|
444 | checking files | |
|
445 | 1 files, 1 changesets, 1 total revisions | |
|
446 | ||
|
447 | $ cd .. | |
|
448 | ||
|
449 | Multiple I/O errors after transaction open are handled. | |
|
450 | This is effectively what happens if a peer disconnects in the middle | |
|
451 | of a transaction. | |
|
452 | ||
|
453 | $ hg init ioerror-multiple | |
|
454 | $ cd ioerror-multiple | |
|
455 | $ echo 0 > foo | |
|
456 | $ hg -q commit -A -m initial | |
|
457 | warn during pretxncommit | |
|
458 | warn during pretxnclose | |
|
459 | warn during txnclose | |
|
460 | ||
|
461 | $ echo 1 > foo | |
|
462 | ||
|
463 | $ hg --config ui.ioerrors=pretxncommit,pretxnclose,txnclose,txnabort,msgabort,msgrollback commit -m 'multiple errors' | |
|
464 | error: pretxncommit.badui hook raised an exception: [Errno *] simulated epipe (glob) | |
|
465 | abort: simulated ebadf | |
|
466 | *: DeprecationWarning: use lock.release instead of del lock (glob) | |
|
467 | return -1 | |
|
468 | [255] | |
|
469 | ||
|
470 | $ hg verify | |
|
471 | abandoned transaction found - run hg recover | |
|
472 | checking changesets | |
|
473 | checking manifests | |
|
474 | manifest@?: rev 1 points to nonexistent changeset 1 | |
|
475 | manifest@?: 94e0ee43dbfe not in changesets | |
|
476 | crosschecking files in changesets and manifests | |
|
477 | checking files | |
|
478 | foo@?: rev 1 points to nonexistent changeset 1 | |
|
479 | (expected 0) | |
|
480 | 1 files, 1 changesets, 2 total revisions | |
|
481 | 1 warnings encountered! | |
|
482 | 3 integrity errors encountered! | |
|
483 | [1] | |
|
484 | ||
|
485 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now