Show More
@@ -1,458 +1,466 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 | new changesets 23b0221f3370:068774709090 |
|
138 | 138 | updating to branch default |
|
139 | 139 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
140 | 140 | $ cd u |
|
141 | 141 | $ hg id default |
|
142 | 142 | 068774709090 |
|
143 | 143 | |
|
144 | 144 | now rollback and observe that 'hg serve' reloads the repository and |
|
145 | 145 | presents the correct tip changeset: |
|
146 | 146 | |
|
147 | 147 | $ hg -R ../t rollback |
|
148 | 148 | repository tip rolled back to revision 1 (undo commit) |
|
149 | 149 | working directory now based on revision 0 |
|
150 | 150 | $ hg id default |
|
151 | 151 | 791dd2169706 |
|
152 | 152 | |
|
153 | 153 | $ killdaemons.py |
|
154 | 154 | #endif |
|
155 | 155 | |
|
156 | 156 | update to older changeset and then refuse rollback, because |
|
157 | 157 | that would lose data (issue2998) |
|
158 | 158 | $ cd ../t |
|
159 | 159 | $ hg -q update |
|
160 | 160 | $ rm `hg status -un` |
|
161 | 161 | $ template='{rev}:{node|short} [{branch}] {desc|firstline}\n' |
|
162 | 162 | $ echo 'valuable new file' > b |
|
163 | 163 | $ echo 'valuable modification' >> a |
|
164 | 164 | $ hg commit -A -m'a valuable change' |
|
165 | 165 | adding b |
|
166 | 166 | $ hg update 0 |
|
167 | 167 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
168 | 168 | $ hg rollback |
|
169 | 169 | abort: rollback of last commit while not checked out may lose data |
|
170 | 170 | (use -f to force) |
|
171 | 171 | [255] |
|
172 | 172 | $ hg tip -q |
|
173 | 173 | 2:4d9cd3795eea |
|
174 | 174 | $ hg rollback -f |
|
175 | 175 | repository tip rolled back to revision 1 (undo commit) |
|
176 | 176 | $ hg status |
|
177 | 177 | $ hg log --removed b # yep, it's gone |
|
178 | 178 | |
|
179 | 179 | same again, but emulate an old client that doesn't write undo.desc |
|
180 | 180 | $ hg -q update |
|
181 | 181 | $ echo 'valuable modification redux' >> a |
|
182 | 182 | $ hg commit -m'a valuable change redux' |
|
183 | 183 | $ rm .hg/undo.desc |
|
184 | 184 | $ hg update 0 |
|
185 | 185 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
186 | 186 | $ hg rollback |
|
187 | 187 | rolling back unknown transaction |
|
188 | 188 | $ cat a |
|
189 | 189 | a |
|
190 | 190 | |
|
191 | 191 | corrupt journal test |
|
192 | 192 | $ echo "foo" > .hg/store/journal |
|
193 | 193 | $ hg recover |
|
194 | 194 | rolling back interrupted transaction |
|
195 | 195 | couldn't read journal entry 'foo\n'! |
|
196 | 196 | checking changesets |
|
197 | 197 | checking manifests |
|
198 | 198 | crosschecking files in changesets and manifests |
|
199 | 199 | checking files |
|
200 | 200 | 1 files, 2 changesets, 2 total revisions |
|
201 | 201 | |
|
202 | 202 | rollback disabled by config |
|
203 | 203 | $ cat >> $HGRCPATH <<EOF |
|
204 | 204 | > [ui] |
|
205 | 205 | > rollback = false |
|
206 | 206 | > EOF |
|
207 | 207 | $ echo narf >> pinky-sayings.txt |
|
208 | 208 | $ hg add pinky-sayings.txt |
|
209 | 209 | $ hg ci -m 'First one.' |
|
210 | 210 | $ hg rollback |
|
211 | 211 | abort: rollback is disabled because it is unsafe |
|
212 | 212 | (see `hg help -v rollback` for information) |
|
213 | 213 | [255] |
|
214 | 214 | |
|
215 | 215 | $ cd .. |
|
216 | 216 | |
|
217 | 217 | I/O errors on stdio are handled properly (issue5658) |
|
218 | 218 | |
|
219 | 219 | $ cat > badui.py << EOF |
|
220 | 220 | > import errno |
|
221 | 221 | > from mercurial.i18n import _ |
|
222 | 222 | > from mercurial import ( |
|
223 | > registrar, | |
|
223 | 224 | > error, |
|
224 | 225 | > ui as uimod, |
|
225 | 226 | > ) |
|
226 | 227 | > |
|
228 | > configtable = {} | |
|
229 | > configitem = registrar.configitem(configtable) | |
|
230 | > | |
|
231 | > configitem('ui', 'ioerrors', | |
|
232 | > default=list, | |
|
233 | > ) | |
|
234 | > | |
|
227 | 235 | > def pretxncommit(ui, repo, **kwargs): |
|
228 | 236 | > ui.warn('warn during pretxncommit\n') |
|
229 | 237 | > |
|
230 | 238 | > def pretxnclose(ui, repo, **kwargs): |
|
231 | 239 | > ui.warn('warn during pretxnclose\n') |
|
232 | 240 | > |
|
233 | 241 | > def txnclose(ui, repo, **kwargs): |
|
234 | 242 | > ui.warn('warn during txnclose\n') |
|
235 | 243 | > |
|
236 | 244 | > def txnabort(ui, repo, **kwargs): |
|
237 | 245 | > ui.warn('warn during abort\n') |
|
238 | 246 | > |
|
239 | 247 | > class fdproxy(object): |
|
240 | 248 | > def __init__(self, ui, o): |
|
241 | 249 | > self._ui = ui |
|
242 | 250 | > self._o = o |
|
243 | 251 | > |
|
244 | 252 | > def __getattr__(self, attr): |
|
245 | 253 | > return getattr(self._o, attr) |
|
246 | 254 | > |
|
247 | 255 | > def write(self, msg): |
|
248 |
> errors = set(self._ui.configlist('ui', 'ioerrors' |
|
|
256 | > errors = set(self._ui.configlist('ui', 'ioerrors')) | |
|
249 | 257 | > pretxncommit = msg == 'warn during pretxncommit\n' |
|
250 | 258 | > pretxnclose = msg == 'warn during pretxnclose\n' |
|
251 | 259 | > txnclose = msg == 'warn during txnclose\n' |
|
252 | 260 | > txnabort = msg == 'warn during abort\n' |
|
253 | 261 | > msgabort = msg == _('transaction abort!\n') |
|
254 | 262 | > msgrollback = msg == _('rollback completed\n') |
|
255 | 263 | > |
|
256 | 264 | > if pretxncommit and 'pretxncommit' in errors: |
|
257 | 265 | > raise IOError(errno.EPIPE, 'simulated epipe') |
|
258 | 266 | > if pretxnclose and 'pretxnclose' in errors: |
|
259 | 267 | > raise IOError(errno.EIO, 'simulated eio') |
|
260 | 268 | > if txnclose and 'txnclose' in errors: |
|
261 | 269 | > raise IOError(errno.EBADF, 'simulated badf') |
|
262 | 270 | > if txnabort and 'txnabort' in errors: |
|
263 | 271 | > raise IOError(errno.EPIPE, 'simulated epipe') |
|
264 | 272 | > if msgabort and 'msgabort' in errors: |
|
265 | 273 | > raise IOError(errno.EBADF, 'simulated ebadf') |
|
266 | 274 | > if msgrollback and 'msgrollback' in errors: |
|
267 | 275 | > raise IOError(errno.EIO, 'simulated eio') |
|
268 | 276 | > |
|
269 | 277 | > return self._o.write(msg) |
|
270 | 278 | > |
|
271 | 279 | > def uisetup(ui): |
|
272 | 280 | > class badui(ui.__class__): |
|
273 | 281 | > def write_err(self, *args, **kwargs): |
|
274 | 282 | > olderr = self.ferr |
|
275 | 283 | > try: |
|
276 | 284 | > self.ferr = fdproxy(self, olderr) |
|
277 | 285 | > return super(badui, self).write_err(*args, **kwargs) |
|
278 | 286 | > finally: |
|
279 | 287 | > self.ferr = olderr |
|
280 | 288 | > |
|
281 | 289 | > ui.__class__ = badui |
|
282 | 290 | > |
|
283 | 291 | > def reposetup(ui, repo): |
|
284 | 292 | > ui.setconfig('hooks', 'pretxnclose.badui', pretxnclose, 'badui') |
|
285 | 293 | > ui.setconfig('hooks', 'txnclose.badui', txnclose, 'badui') |
|
286 | 294 | > ui.setconfig('hooks', 'pretxncommit.badui', pretxncommit, 'badui') |
|
287 | 295 | > ui.setconfig('hooks', 'txnabort.badui', txnabort, 'badui') |
|
288 | 296 | > EOF |
|
289 | 297 | |
|
290 | 298 | $ cat >> $HGRCPATH << EOF |
|
291 | 299 | > [extensions] |
|
292 | 300 | > badui = $TESTTMP/badui.py |
|
293 | 301 | > EOF |
|
294 | 302 | |
|
295 | 303 | An I/O error during pretxncommit is handled |
|
296 | 304 | |
|
297 | 305 | $ hg init ioerror-pretxncommit |
|
298 | 306 | $ cd ioerror-pretxncommit |
|
299 | 307 | $ echo 0 > foo |
|
300 | 308 | $ hg -q commit -A -m initial |
|
301 | 309 | warn during pretxncommit |
|
302 | 310 | warn during pretxnclose |
|
303 | 311 | warn during txnclose |
|
304 | 312 | $ echo 1 > foo |
|
305 | 313 | $ hg --config ui.ioerrors=pretxncommit commit -m 'error during pretxncommit' |
|
306 | 314 | warn during pretxnclose |
|
307 | 315 | warn during txnclose |
|
308 | 316 | |
|
309 | 317 | $ hg commit -m 'commit 1' |
|
310 | 318 | nothing changed |
|
311 | 319 | [1] |
|
312 | 320 | |
|
313 | 321 | $ cd .. |
|
314 | 322 | |
|
315 | 323 | An I/O error during pretxnclose is handled |
|
316 | 324 | |
|
317 | 325 | $ hg init ioerror-pretxnclose |
|
318 | 326 | $ cd ioerror-pretxnclose |
|
319 | 327 | $ echo 0 > foo |
|
320 | 328 | $ hg -q commit -A -m initial |
|
321 | 329 | warn during pretxncommit |
|
322 | 330 | warn during pretxnclose |
|
323 | 331 | warn during txnclose |
|
324 | 332 | |
|
325 | 333 | $ echo 1 > foo |
|
326 | 334 | $ hg --config ui.ioerrors=pretxnclose commit -m 'error during pretxnclose' |
|
327 | 335 | warn during pretxncommit |
|
328 | 336 | warn during txnclose |
|
329 | 337 | |
|
330 | 338 | $ hg commit -m 'commit 1' |
|
331 | 339 | nothing changed |
|
332 | 340 | [1] |
|
333 | 341 | |
|
334 | 342 | $ cd .. |
|
335 | 343 | |
|
336 | 344 | An I/O error during txnclose is handled |
|
337 | 345 | |
|
338 | 346 | $ hg init ioerror-txnclose |
|
339 | 347 | $ cd ioerror-txnclose |
|
340 | 348 | $ echo 0 > foo |
|
341 | 349 | $ hg -q commit -A -m initial |
|
342 | 350 | warn during pretxncommit |
|
343 | 351 | warn during pretxnclose |
|
344 | 352 | warn during txnclose |
|
345 | 353 | |
|
346 | 354 | $ echo 1 > foo |
|
347 | 355 | $ hg --config ui.ioerrors=txnclose commit -m 'error during txnclose' |
|
348 | 356 | warn during pretxncommit |
|
349 | 357 | warn during pretxnclose |
|
350 | 358 | |
|
351 | 359 | $ hg commit -m 'commit 1' |
|
352 | 360 | nothing changed |
|
353 | 361 | [1] |
|
354 | 362 | |
|
355 | 363 | $ cd .. |
|
356 | 364 | |
|
357 | 365 | An I/O error writing "transaction abort" is handled |
|
358 | 366 | |
|
359 | 367 | $ hg init ioerror-msgabort |
|
360 | 368 | $ cd ioerror-msgabort |
|
361 | 369 | |
|
362 | 370 | $ echo 0 > foo |
|
363 | 371 | $ hg -q commit -A -m initial |
|
364 | 372 | warn during pretxncommit |
|
365 | 373 | warn during pretxnclose |
|
366 | 374 | warn during txnclose |
|
367 | 375 | |
|
368 | 376 | $ echo 1 > foo |
|
369 | 377 | $ hg --config ui.ioerrors=msgabort --config hooks.pretxncommit=false commit -m 'error during abort message' |
|
370 | 378 | warn during abort |
|
371 | 379 | rollback completed |
|
372 | 380 | abort: pretxncommit hook exited with status 1 |
|
373 | 381 | [255] |
|
374 | 382 | |
|
375 | 383 | $ hg commit -m 'commit 1' |
|
376 | 384 | warn during pretxncommit |
|
377 | 385 | warn during pretxnclose |
|
378 | 386 | warn during txnclose |
|
379 | 387 | |
|
380 | 388 | $ cd .. |
|
381 | 389 | |
|
382 | 390 | An I/O error during txnabort should still result in rollback |
|
383 | 391 | |
|
384 | 392 | $ hg init ioerror-txnabort |
|
385 | 393 | $ cd ioerror-txnabort |
|
386 | 394 | |
|
387 | 395 | $ echo 0 > foo |
|
388 | 396 | $ hg -q commit -A -m initial |
|
389 | 397 | warn during pretxncommit |
|
390 | 398 | warn during pretxnclose |
|
391 | 399 | warn during txnclose |
|
392 | 400 | |
|
393 | 401 | $ echo 1 > foo |
|
394 | 402 | $ hg --config ui.ioerrors=txnabort --config hooks.pretxncommit=false commit -m 'error during abort' |
|
395 | 403 | transaction abort! |
|
396 | 404 | rollback completed |
|
397 | 405 | abort: pretxncommit hook exited with status 1 |
|
398 | 406 | [255] |
|
399 | 407 | |
|
400 | 408 | $ hg commit -m 'commit 1' |
|
401 | 409 | warn during pretxncommit |
|
402 | 410 | warn during pretxnclose |
|
403 | 411 | warn during txnclose |
|
404 | 412 | |
|
405 | 413 | $ cd .. |
|
406 | 414 | |
|
407 | 415 | An I/O error writing "rollback completed" is handled |
|
408 | 416 | |
|
409 | 417 | $ hg init ioerror-msgrollback |
|
410 | 418 | $ cd ioerror-msgrollback |
|
411 | 419 | |
|
412 | 420 | $ echo 0 > foo |
|
413 | 421 | $ hg -q commit -A -m initial |
|
414 | 422 | warn during pretxncommit |
|
415 | 423 | warn during pretxnclose |
|
416 | 424 | warn during txnclose |
|
417 | 425 | |
|
418 | 426 | $ echo 1 > foo |
|
419 | 427 | |
|
420 | 428 | $ hg --config ui.ioerrors=msgrollback --config hooks.pretxncommit=false commit -m 'error during rollback message' |
|
421 | 429 | transaction abort! |
|
422 | 430 | warn during abort |
|
423 | 431 | abort: pretxncommit hook exited with status 1 |
|
424 | 432 | [255] |
|
425 | 433 | |
|
426 | 434 | $ hg verify |
|
427 | 435 | checking changesets |
|
428 | 436 | checking manifests |
|
429 | 437 | crosschecking files in changesets and manifests |
|
430 | 438 | checking files |
|
431 | 439 | 1 files, 1 changesets, 1 total revisions |
|
432 | 440 | |
|
433 | 441 | $ cd .. |
|
434 | 442 | |
|
435 | 443 | Multiple I/O errors after transaction open are handled. |
|
436 | 444 | This is effectively what happens if a peer disconnects in the middle |
|
437 | 445 | of a transaction. |
|
438 | 446 | |
|
439 | 447 | $ hg init ioerror-multiple |
|
440 | 448 | $ cd ioerror-multiple |
|
441 | 449 | $ echo 0 > foo |
|
442 | 450 | $ hg -q commit -A -m initial |
|
443 | 451 | warn during pretxncommit |
|
444 | 452 | warn during pretxnclose |
|
445 | 453 | warn during txnclose |
|
446 | 454 | |
|
447 | 455 | $ echo 1 > foo |
|
448 | 456 | |
|
449 | 457 | $ hg --config ui.ioerrors=pretxncommit,pretxnclose,txnclose,txnabort,msgabort,msgrollback commit -m 'multiple errors' |
|
450 | 458 | |
|
451 | 459 | $ hg verify |
|
452 | 460 | checking changesets |
|
453 | 461 | checking manifests |
|
454 | 462 | crosschecking files in changesets and manifests |
|
455 | 463 | checking files |
|
456 | 464 | 1 files, 2 changesets, 2 total revisions |
|
457 | 465 | |
|
458 | 466 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now