##// END OF EJS Templates
test-revert: add case where file is unchanged between "base" and "parent"...
Pierre-Yves David -
r22135:37d2bd2c default
parent child Browse files
Show More
@@ -1,671 +1,690 b''
1 $ hg init repo
1 $ hg init repo
2 $ cd repo
2 $ cd repo
3 $ echo 123 > a
3 $ echo 123 > a
4 $ echo 123 > c
4 $ echo 123 > c
5 $ echo 123 > e
5 $ echo 123 > e
6 $ hg add a c e
6 $ hg add a c e
7 $ hg commit -m "first" a c e
7 $ hg commit -m "first" a c e
8
8
9 nothing changed
9 nothing changed
10
10
11 $ hg revert
11 $ hg revert
12 abort: no files or directories specified
12 abort: no files or directories specified
13 (use --all to revert all files)
13 (use --all to revert all files)
14 [255]
14 [255]
15 $ hg revert --all
15 $ hg revert --all
16
16
17 Introduce some changes and revert them
17 Introduce some changes and revert them
18 --------------------------------------
18 --------------------------------------
19
19
20 $ echo 123 > b
20 $ echo 123 > b
21
21
22 $ hg status
22 $ hg status
23 ? b
23 ? b
24 $ echo 12 > c
24 $ echo 12 > c
25
25
26 $ hg status
26 $ hg status
27 M c
27 M c
28 ? b
28 ? b
29 $ hg add b
29 $ hg add b
30
30
31 $ hg status
31 $ hg status
32 M c
32 M c
33 A b
33 A b
34 $ hg rm a
34 $ hg rm a
35
35
36 $ hg status
36 $ hg status
37 M c
37 M c
38 A b
38 A b
39 R a
39 R a
40
40
41 revert removal of a file
41 revert removal of a file
42
42
43 $ hg revert a
43 $ hg revert a
44 $ hg status
44 $ hg status
45 M c
45 M c
46 A b
46 A b
47
47
48 revert addition of a file
48 revert addition of a file
49
49
50 $ hg revert b
50 $ hg revert b
51 $ hg status
51 $ hg status
52 M c
52 M c
53 ? b
53 ? b
54
54
55 revert modification of a file (--no-backup)
55 revert modification of a file (--no-backup)
56
56
57 $ hg revert --no-backup c
57 $ hg revert --no-backup c
58 $ hg status
58 $ hg status
59 ? b
59 ? b
60
60
61 revert deletion (! status) of a added file
61 revert deletion (! status) of a added file
62 ------------------------------------------
62 ------------------------------------------
63
63
64 $ hg add b
64 $ hg add b
65
65
66 $ hg status b
66 $ hg status b
67 A b
67 A b
68 $ rm b
68 $ rm b
69 $ hg status b
69 $ hg status b
70 ! b
70 ! b
71 $ hg revert -v b
71 $ hg revert -v b
72 forgetting b
72 forgetting b
73 $ hg status b
73 $ hg status b
74 b: * (glob)
74 b: * (glob)
75
75
76 $ ls
76 $ ls
77 a
77 a
78 c
78 c
79 e
79 e
80
80
81 Test creation of backup (.orig) files
81 Test creation of backup (.orig) files
82 -------------------------------------
82 -------------------------------------
83
83
84 $ echo z > e
84 $ echo z > e
85 $ hg revert --all -v
85 $ hg revert --all -v
86 saving current version of e as e.orig
86 saving current version of e as e.orig
87 reverting e
87 reverting e
88
88
89 revert on clean file (no change)
89 revert on clean file (no change)
90 --------------------------------
90 --------------------------------
91
91
92 $ hg revert a
92 $ hg revert a
93 no changes needed to a
93 no changes needed to a
94
94
95 revert on an untracked file
95 revert on an untracked file
96 ---------------------------
96 ---------------------------
97
97
98 $ echo q > q
98 $ echo q > q
99 $ hg revert q
99 $ hg revert q
100 file not managed: q
100 file not managed: q
101 $ rm q
101 $ rm q
102
102
103 revert on file that does not exists
103 revert on file that does not exists
104 -----------------------------------
104 -----------------------------------
105
105
106 $ hg revert notfound
106 $ hg revert notfound
107 notfound: no such file in rev 334a9e57682c
107 notfound: no such file in rev 334a9e57682c
108 $ touch d
108 $ touch d
109 $ hg add d
109 $ hg add d
110 $ hg rm a
110 $ hg rm a
111 $ hg commit -m "second"
111 $ hg commit -m "second"
112 $ echo z > z
112 $ echo z > z
113 $ hg add z
113 $ hg add z
114 $ hg st
114 $ hg st
115 A z
115 A z
116 ? e.orig
116 ? e.orig
117
117
118 revert to another revision (--rev)
118 revert to another revision (--rev)
119 ----------------------------------
119 ----------------------------------
120
120
121 $ hg revert --all -r0
121 $ hg revert --all -r0
122 adding a
122 adding a
123 removing d
123 removing d
124 forgetting z
124 forgetting z
125
125
126 revert explicitly to parent (--rev)
126 revert explicitly to parent (--rev)
127 -----------------------------------
127 -----------------------------------
128
128
129 $ hg revert --all -rtip
129 $ hg revert --all -rtip
130 forgetting a
130 forgetting a
131 undeleting d
131 undeleting d
132 $ rm a *.orig
132 $ rm a *.orig
133
133
134 revert to another revision (--rev) and exact match
134 revert to another revision (--rev) and exact match
135 --------------------------------------------------
135 --------------------------------------------------
136
136
137 exact match are more silent
137 exact match are more silent
138
138
139 $ hg revert -r0 a
139 $ hg revert -r0 a
140 $ hg st a
140 $ hg st a
141 A a
141 A a
142 $ hg rm d
142 $ hg rm d
143 $ hg st d
143 $ hg st d
144 R d
144 R d
145
145
146 should silently keep d removed
146 should silently keep d removed
147
147
148 $ hg revert -r0 d
148 $ hg revert -r0 d
149 $ hg st d
149 $ hg st d
150 R d
150 R d
151
151
152 $ hg update -C
152 $ hg update -C
153 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
153 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
154
154
155 revert of exec bit
155 revert of exec bit
156 ------------------
156 ------------------
157
157
158 #if execbit
158 #if execbit
159 $ chmod +x c
159 $ chmod +x c
160 $ hg revert --all
160 $ hg revert --all
161 reverting c
161 reverting c
162
162
163 $ test -x c || echo non-executable
163 $ test -x c || echo non-executable
164 non-executable
164 non-executable
165
165
166 $ chmod +x c
166 $ chmod +x c
167 $ hg commit -m exe
167 $ hg commit -m exe
168
168
169 $ chmod -x c
169 $ chmod -x c
170 $ hg revert --all
170 $ hg revert --all
171 reverting c
171 reverting c
172
172
173 $ test -x c && echo executable
173 $ test -x c && echo executable
174 executable
174 executable
175 #endif
175 #endif
176
176
177 $ cd ..
177 $ cd ..
178
178
179
179
180 Issue241: update and revert produces inconsistent repositories
180 Issue241: update and revert produces inconsistent repositories
181 --------------------------------------------------------------
181 --------------------------------------------------------------
182
182
183 $ hg init a
183 $ hg init a
184 $ cd a
184 $ cd a
185 $ echo a >> a
185 $ echo a >> a
186 $ hg commit -A -d '1 0' -m a
186 $ hg commit -A -d '1 0' -m a
187 adding a
187 adding a
188 $ echo a >> a
188 $ echo a >> a
189 $ hg commit -d '2 0' -m a
189 $ hg commit -d '2 0' -m a
190 $ hg update 0
190 $ hg update 0
191 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
191 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
192 $ mkdir b
192 $ mkdir b
193 $ echo b > b/b
193 $ echo b > b/b
194
194
195 call `hg revert` with no file specified
195 call `hg revert` with no file specified
196 ---------------------------------------
196 ---------------------------------------
197
197
198 $ hg revert -rtip
198 $ hg revert -rtip
199 abort: no files or directories specified
199 abort: no files or directories specified
200 (use --all to revert all files, or 'hg update 1' to update)
200 (use --all to revert all files, or 'hg update 1' to update)
201 [255]
201 [255]
202
202
203 call `hg revert` with --all
203 call `hg revert` with --all
204 ---------------------------
204 ---------------------------
205
205
206 $ hg revert --all -rtip
206 $ hg revert --all -rtip
207 reverting a
207 reverting a
208
208
209
209
210 Issue332: confusing message when reverting directory
210 Issue332: confusing message when reverting directory
211 ----------------------------------------------------
211 ----------------------------------------------------
212
212
213 $ hg ci -A -m b
213 $ hg ci -A -m b
214 adding b/b
214 adding b/b
215 created new head
215 created new head
216 $ echo foobar > b/b
216 $ echo foobar > b/b
217 $ mkdir newdir
217 $ mkdir newdir
218 $ echo foo > newdir/newfile
218 $ echo foo > newdir/newfile
219 $ hg add newdir/newfile
219 $ hg add newdir/newfile
220 $ hg revert b newdir
220 $ hg revert b newdir
221 reverting b/b (glob)
221 reverting b/b (glob)
222 forgetting newdir/newfile (glob)
222 forgetting newdir/newfile (glob)
223 $ echo foobar > b/b
223 $ echo foobar > b/b
224 $ hg revert .
224 $ hg revert .
225 reverting b/b (glob)
225 reverting b/b (glob)
226
226
227
227
228 reverting a rename target should revert the source
228 reverting a rename target should revert the source
229 --------------------------------------------------
229 --------------------------------------------------
230
230
231 $ hg mv a newa
231 $ hg mv a newa
232 $ hg revert newa
232 $ hg revert newa
233 $ hg st a newa
233 $ hg st a newa
234 ? newa
234 ? newa
235
235
236 $ cd ..
236 $ cd ..
237
237
238 $ hg init ignored
238 $ hg init ignored
239 $ cd ignored
239 $ cd ignored
240 $ echo '^ignored$' > .hgignore
240 $ echo '^ignored$' > .hgignore
241 $ echo '^ignoreddir$' >> .hgignore
241 $ echo '^ignoreddir$' >> .hgignore
242 $ echo '^removed$' >> .hgignore
242 $ echo '^removed$' >> .hgignore
243
243
244 $ mkdir ignoreddir
244 $ mkdir ignoreddir
245 $ touch ignoreddir/file
245 $ touch ignoreddir/file
246 $ touch ignoreddir/removed
246 $ touch ignoreddir/removed
247 $ touch ignored
247 $ touch ignored
248 $ touch removed
248 $ touch removed
249
249
250 4 ignored files (we will add/commit everything)
250 4 ignored files (we will add/commit everything)
251
251
252 $ hg st -A -X .hgignore
252 $ hg st -A -X .hgignore
253 I ignored
253 I ignored
254 I ignoreddir/file
254 I ignoreddir/file
255 I ignoreddir/removed
255 I ignoreddir/removed
256 I removed
256 I removed
257 $ hg ci -qAm 'add files' ignored ignoreddir/file ignoreddir/removed removed
257 $ hg ci -qAm 'add files' ignored ignoreddir/file ignoreddir/removed removed
258
258
259 $ echo >> ignored
259 $ echo >> ignored
260 $ echo >> ignoreddir/file
260 $ echo >> ignoreddir/file
261 $ hg rm removed ignoreddir/removed
261 $ hg rm removed ignoreddir/removed
262
262
263 should revert ignored* and undelete *removed
263 should revert ignored* and undelete *removed
264 --------------------------------------------
264 --------------------------------------------
265
265
266 $ hg revert -a --no-backup
266 $ hg revert -a --no-backup
267 reverting ignored
267 reverting ignored
268 reverting ignoreddir/file (glob)
268 reverting ignoreddir/file (glob)
269 undeleting ignoreddir/removed (glob)
269 undeleting ignoreddir/removed (glob)
270 undeleting removed
270 undeleting removed
271 $ hg st -mardi
271 $ hg st -mardi
272
272
273 $ hg up -qC
273 $ hg up -qC
274 $ echo >> ignored
274 $ echo >> ignored
275 $ hg rm removed
275 $ hg rm removed
276
276
277 should silently revert the named files
277 should silently revert the named files
278 --------------------------------------
278 --------------------------------------
279
279
280 $ hg revert --no-backup ignored removed
280 $ hg revert --no-backup ignored removed
281 $ hg st -mardi
281 $ hg st -mardi
282
282
283 Reverting copy (issue3920)
283 Reverting copy (issue3920)
284 --------------------------
284 --------------------------
285
285
286 someone set up us the copies
286 someone set up us the copies
287
287
288 $ rm .hgignore
288 $ rm .hgignore
289 $ hg update -C
289 $ hg update -C
290 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
290 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
291 $ hg mv ignored allyour
291 $ hg mv ignored allyour
292 $ hg copy removed base
292 $ hg copy removed base
293 $ hg commit -m rename
293 $ hg commit -m rename
294
294
295 copies and renames, you have no chance to survive make your time (issue3920)
295 copies and renames, you have no chance to survive make your time (issue3920)
296
296
297 $ hg update '.^'
297 $ hg update '.^'
298 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
298 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
299 $ hg revert -rtip -a
299 $ hg revert -rtip -a
300 adding allyour
300 adding allyour
301 adding base
301 adding base
302 removing ignored
302 removing ignored
303 $ hg status -C
303 $ hg status -C
304 A allyour
304 A allyour
305 ignored
305 ignored
306 A base
306 A base
307 removed
307 removed
308 R ignored
308 R ignored
309
309
310 Test revert of a file added by one side of the merge
310 Test revert of a file added by one side of the merge
311 ====================================================
311 ====================================================
312
312
313 remove any pending change
313 remove any pending change
314
314
315 $ hg revert --all
315 $ hg revert --all
316 forgetting allyour
316 forgetting allyour
317 forgetting base
317 forgetting base
318 undeleting ignored
318 undeleting ignored
319 $ hg purge --all --config extensions.purge=
319 $ hg purge --all --config extensions.purge=
320
320
321 Adds a new commit
321 Adds a new commit
322
322
323 $ echo foo > newadd
323 $ echo foo > newadd
324 $ hg add newadd
324 $ hg add newadd
325 $ hg commit -m 'other adds'
325 $ hg commit -m 'other adds'
326 created new head
326 created new head
327
327
328
328
329 merge it with the other head
329 merge it with the other head
330
330
331 $ hg merge # merge 1 into 2
331 $ hg merge # merge 1 into 2
332 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
332 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
333 (branch merge, don't forget to commit)
333 (branch merge, don't forget to commit)
334 $ hg summary
334 $ hg summary
335 parent: 2:b8ec310b2d4e tip
335 parent: 2:b8ec310b2d4e tip
336 other adds
336 other adds
337 parent: 1:f6180deb8fbe
337 parent: 1:f6180deb8fbe
338 rename
338 rename
339 branch: default
339 branch: default
340 commit: 2 modified, 1 removed (merge)
340 commit: 2 modified, 1 removed (merge)
341 update: (current)
341 update: (current)
342
342
343 clarifies who added what
343 clarifies who added what
344
344
345 $ hg status
345 $ hg status
346 M allyour
346 M allyour
347 M base
347 M base
348 R ignored
348 R ignored
349 $ hg status --change 'p1()'
349 $ hg status --change 'p1()'
350 A newadd
350 A newadd
351 $ hg status --change 'p2()'
351 $ hg status --change 'p2()'
352 A allyour
352 A allyour
353 A base
353 A base
354 R ignored
354 R ignored
355
355
356 revert file added by p1() to p1() state
356 revert file added by p1() to p1() state
357 -----------------------------------------
357 -----------------------------------------
358
358
359 $ hg revert -r 'p1()' 'glob:newad?'
359 $ hg revert -r 'p1()' 'glob:newad?'
360 $ hg status
360 $ hg status
361 M allyour
361 M allyour
362 M base
362 M base
363 R ignored
363 R ignored
364
364
365 revert file added by p1() to p2() state
365 revert file added by p1() to p2() state
366 ------------------------------------------
366 ------------------------------------------
367
367
368 $ hg revert -r 'p2()' 'glob:newad?'
368 $ hg revert -r 'p2()' 'glob:newad?'
369 removing newadd
369 removing newadd
370 $ hg status
370 $ hg status
371 M allyour
371 M allyour
372 M base
372 M base
373 R ignored
373 R ignored
374 R newadd
374 R newadd
375
375
376 revert file added by p2() to p2() state
376 revert file added by p2() to p2() state
377 ------------------------------------------
377 ------------------------------------------
378
378
379 $ hg revert -r 'p2()' 'glob:allyou?'
379 $ hg revert -r 'p2()' 'glob:allyou?'
380 $ hg status
380 $ hg status
381 M allyour
381 M allyour
382 M base
382 M base
383 R ignored
383 R ignored
384 R newadd
384 R newadd
385
385
386 revert file added by p2() to p1() state
386 revert file added by p2() to p1() state
387 ------------------------------------------
387 ------------------------------------------
388
388
389 $ hg revert -r 'p1()' 'glob:allyou?'
389 $ hg revert -r 'p1()' 'glob:allyou?'
390 removing allyour
390 removing allyour
391 $ hg status
391 $ hg status
392 M base
392 M base
393 R allyour
393 R allyour
394 R ignored
394 R ignored
395 R newadd
395 R newadd
396
396
397 Systematic behavior validation of most possible cases
397 Systematic behavior validation of most possible cases
398 =====================================================
398 =====================================================
399
399
400 This section tests most of the possible combinations of working directory
400 This section tests most of the possible combinations of working directory
401 changes and inter-revision changes. The number of possible cases is significant
401 changes and inter-revision changes. The number of possible cases is significant
402 but they all have a slighly different handling. So this section commits to
402 but they all have a slighly different handling. So this section commits to
403 generating and testing all of them to allow safe refactoring of the revert code.
403 generating and testing all of them to allow safe refactoring of the revert code.
404
404
405 A python script is used to generate a file history for each combination of
405 A python script is used to generate a file history for each combination of
406 changes between, on one side the working directory and its parent and on
406 changes between, on one side the working directory and its parent and on
407 the other side, changes between a revert target (--rev) and working directory
407 the other side, changes between a revert target (--rev) and working directory
408 parent. The three states generated are:
408 parent. The three states generated are:
409
409
410 - a "base" revision
410 - a "base" revision
411 - a "parent" revision
411 - a "parent" revision
412 - the working directory (based on "parent")
412 - the working directory (based on "parent")
413
413
414 The file generated have names of the form:
414 The file generated have names of the form:
415
415
416 <changeset-state>_<working-copy-state>
416 <changeset-state>_<working-copy-state>
417
417
418 Here, "changeset-state" conveys the state in "base" and "parent" (or the change
418 Here, "changeset-state" conveys the state in "base" and "parent" (or the change
419 that happen between them), "working-copy-state" is self explanatory.
419 that happen between them), "working-copy-state" is self explanatory.
420
420
421 All known states are not tested yet. See inline documentation for details.
421 All known states are not tested yet. See inline documentation for details.
422 Special cases from merge and rename are not tested by this section.
422 Special cases from merge and rename are not tested by this section.
423
423
424 There are also multiple cases where the current revert implementation is known to
424 There are also multiple cases where the current revert implementation is known to
425 slightly misbehave.
425 slightly misbehave.
426
426
427 Write the python script to disk
427 Write the python script to disk
428 -------------------------------
428 -------------------------------
429
429
430 $ cat << EOF > gen-revert-cases.py
430 $ cat << EOF > gen-revert-cases.py
431 > # generate proper file state to test revert behavior
431 > # generate proper file state to test revert behavior
432 > import sys
432 > import sys
433 > import os
433 > import os
434 >
434 >
435 > # content of the file in "base" and "parent"
435 > # content of the file in "base" and "parent"
436 > # None means no file at all
436 > # None means no file at all
437 > ctxcontent = {
437 > ctxcontent = {
438 > # clean: no change from base to parent
439 > 'clean': ['base', 'base'],
438 > # modified: file content change from base to parent
440 > # modified: file content change from base to parent
439 > 'modified': ['base', 'parent'],
441 > 'modified': ['base', 'parent'],
440 > # added: file is missing from base and added in parent
442 > # added: file is missing from base and added in parent
441 > 'added': [None, 'parent'],
443 > 'added': [None, 'parent'],
442 > }
444 > }
443 >
445 >
444 > # content of file in working copy
446 > # content of file in working copy
445 > wccontent = {
447 > wccontent = {
446 > # clean: wc content is the same as parent
448 > # clean: wc content is the same as parent
447 > 'clean': lambda cc: cc[1],
449 > 'clean': lambda cc: cc[1],
448 > }
450 > }
449 >
451 >
450 > # build the combination of possible states
452 > # build the combination of possible states
451 > combination = []
453 > combination = []
452 > for ctxkey in ctxcontent:
454 > for ctxkey in ctxcontent:
453 > for wckey in wccontent:
455 > for wckey in wccontent:
454 > filename = "%s_%s" % (ctxkey, wckey)
456 > filename = "%s_%s" % (ctxkey, wckey)
455 > combination.append((filename, ctxkey, wckey))
457 > combination.append((filename, ctxkey, wckey))
456 >
458 >
457 > # make sure we have stable output
459 > # make sure we have stable output
458 > combination.sort()
460 > combination.sort()
459 >
461 >
460 > # retrieve the state we must generate
462 > # retrieve the state we must generate
461 > target = sys.argv[1]
463 > target = sys.argv[1]
462 >
464 >
463 > # compute file content
465 > # compute file content
464 > content = []
466 > content = []
465 > for filename, ctxkey, wckey in combination:
467 > for filename, ctxkey, wckey in combination:
466 > cc = ctxcontent[ctxkey]
468 > cc = ctxcontent[ctxkey]
467 > if target == 'filelist':
469 > if target == 'filelist':
468 > print filename
470 > print filename
469 > elif target == 'base':
471 > elif target == 'base':
470 > content.append((filename, cc[0]))
472 > content.append((filename, cc[0]))
471 > elif target == 'parent':
473 > elif target == 'parent':
472 > content.append((filename, cc[1]))
474 > content.append((filename, cc[1]))
473 > elif target == 'wc':
475 > elif target == 'wc':
474 > content.append((filename, wccontent[wckey](cc)))
476 > content.append((filename, wccontent[wckey](cc)))
475 > else:
477 > else:
476 > print >> sys.stderr, "unknown target:", target
478 > print >> sys.stderr, "unknown target:", target
477 > sys.exit(1)
479 > sys.exit(1)
478 >
480 >
479 > # write actual content
481 > # write actual content
480 > for filename, data in content:
482 > for filename, data in content:
481 > if data is not None:
483 > if data is not None:
482 > f = open(filename, 'w')
484 > f = open(filename, 'w')
483 > f.write(data + '\n')
485 > f.write(data + '\n')
484 > f.close()
486 > f.close()
485 > elif os.path.exists(filename):
487 > elif os.path.exists(filename):
486 > os.remove(filename)
488 > os.remove(filename)
487 > EOF
489 > EOF
488
490
489 check list of planned files
491 check list of planned files
490
492
491 $ python gen-revert-cases.py filelist
493 $ python gen-revert-cases.py filelist
492 added_clean
494 added_clean
495 clean_clean
493 modified_clean
496 modified_clean
494
497
495 Script to make a simple text version of the content
498 Script to make a simple text version of the content
496 ---------------------------------------------------
499 ---------------------------------------------------
497
500
498 $ cat << EOF >> dircontent.py
501 $ cat << EOF >> dircontent.py
499 > # generate a simple text view of the directory for easy comparison
502 > # generate a simple text view of the directory for easy comparison
500 > import os
503 > import os
501 > files = os.listdir('.')
504 > files = os.listdir('.')
502 > files.sort()
505 > files.sort()
503 > for filename in files:
506 > for filename in files:
504 > if os.path.isdir(filename):
507 > if os.path.isdir(filename):
505 > continue
508 > continue
506 > content = open(filename).read()
509 > content = open(filename).read()
507 > print '%-6s %s' % (content.strip(), filename)
510 > print '%-6s %s' % (content.strip(), filename)
508 > EOF
511 > EOF
509
512
510 Generate appropriate repo state
513 Generate appropriate repo state
511 -------------------------------
514 -------------------------------
512
515
513 $ hg init revert-ref
516 $ hg init revert-ref
514 $ cd revert-ref
517 $ cd revert-ref
515
518
516 Generate base changeset
519 Generate base changeset
517
520
518 $ python ../gen-revert-cases.py base
521 $ python ../gen-revert-cases.py base
519 $ hg addremove --similarity 0
522 $ hg addremove --similarity 0
523 adding clean_clean
520 adding modified_clean
524 adding modified_clean
521 $ hg status
525 $ hg status
526 A clean_clean
522 A modified_clean
527 A modified_clean
523 $ hg commit -m 'base'
528 $ hg commit -m 'base'
524
529
525 (create a simple text version of the content)
530 (create a simple text version of the content)
526
531
527 $ python ../dircontent.py > ../content-base.txt
532 $ python ../dircontent.py > ../content-base.txt
528 $ cat ../content-base.txt
533 $ cat ../content-base.txt
534 base clean_clean
529 base modified_clean
535 base modified_clean
530
536
531 Create parent changeset
537 Create parent changeset
532
538
533 $ python ../gen-revert-cases.py parent
539 $ python ../gen-revert-cases.py parent
534 $ hg addremove --similarity 0
540 $ hg addremove --similarity 0
535 adding added_clean
541 adding added_clean
536 $ hg status
542 $ hg status
537 M modified_clean
543 M modified_clean
538 A added_clean
544 A added_clean
539 $ hg commit -m 'parent'
545 $ hg commit -m 'parent'
540
546
541 (create a simple text version of the content)
547 (create a simple text version of the content)
542
548
543 $ python ../dircontent.py > ../content-parent.txt
549 $ python ../dircontent.py > ../content-parent.txt
544 $ cat ../content-parent.txt
550 $ cat ../content-parent.txt
545 parent added_clean
551 parent added_clean
552 base clean_clean
546 parent modified_clean
553 parent modified_clean
547
554
548 Setup working directory
555 Setup working directory
549
556
550 $ python ../gen-revert-cases.py wc | cat
557 $ python ../gen-revert-cases.py wc | cat
551 $ hg addremove --similarity 0
558 $ hg addremove --similarity 0
552 $ hg status
559 $ hg status
553
560
554 $ hg status --rev 'desc("base")'
561 $ hg status --rev 'desc("base")'
555 M modified_clean
562 M modified_clean
556 A added_clean
563 A added_clean
557
564
558 (create a simple text version of the content)
565 (create a simple text version of the content)
559
566
560 $ python ../dircontent.py > ../content-wc.txt
567 $ python ../dircontent.py > ../content-wc.txt
561 $ cat ../content-wc.txt
568 $ cat ../content-wc.txt
562 parent added_clean
569 parent added_clean
570 base clean_clean
563 parent modified_clean
571 parent modified_clean
564
572
565 $ cd ..
573 $ cd ..
566
574
567 Test revert --all to parent content
575 Test revert --all to parent content
568 -----------------------------------
576 -----------------------------------
569
577
570 (setup from reference repo)
578 (setup from reference repo)
571
579
572 $ cp -r revert-ref revert-parent-all
580 $ cp -r revert-ref revert-parent-all
573 $ cd revert-parent-all
581 $ cd revert-parent-all
574
582
575 check revert output
583 check revert output
576
584
577 $ hg revert --all
585 $ hg revert --all
578
586
579 Compare resulting directory with revert target.
587 Compare resulting directory with revert target.
580
588
581 The diff is filtered to include change only. The only difference should be
589 The diff is filtered to include change only. The only difference should be
582 additional `.orig` backup file when applicable.
590 additional `.orig` backup file when applicable.
583
591
584 $ python ../dircontent.py > ../content-parent-all.txt
592 $ python ../dircontent.py > ../content-parent-all.txt
585 $ cd ..
593 $ cd ..
586 $ diff -U 0 -- content-parent.txt content-parent-all.txt | grep _
594 $ diff -U 0 -- content-parent.txt content-parent-all.txt | grep _
587 [1]
595 [1]
588
596
589 Test revert --all to "base" content
597 Test revert --all to "base" content
590 -----------------------------------
598 -----------------------------------
591
599
592 (setup from reference repo)
600 (setup from reference repo)
593
601
594 $ cp -r revert-ref revert-base-all
602 $ cp -r revert-ref revert-base-all
595 $ cd revert-base-all
603 $ cd revert-base-all
596
604
597 check revert output
605 check revert output
598
606
599 $ hg revert --all --rev 'desc(base)'
607 $ hg revert --all --rev 'desc(base)'
600 removing added_clean
608 removing added_clean
601 reverting modified_clean
609 reverting modified_clean
602
610
603 Compare resulting directory with revert target.
611 Compare resulting directory with revert target.
604
612
605 The diff is filtered to include change only. The only difference should be
613 The diff is filtered to include change only. The only difference should be
606 additional `.orig` backup file when applicable.
614 additional `.orig` backup file when applicable.
607
615
608 $ python ../dircontent.py > ../content-base-all.txt
616 $ python ../dircontent.py > ../content-base-all.txt
609 $ cd ..
617 $ cd ..
610 $ diff -U 0 -- content-base.txt content-base-all.txt | grep _
618 $ diff -U 0 -- content-base.txt content-base-all.txt | grep _
611 [1]
619 [1]
612
620
613 Test revert to parent content with explicit file name
621 Test revert to parent content with explicit file name
614 -----------------------------------------------------
622 -----------------------------------------------------
615
623
616 (setup from reference repo)
624 (setup from reference repo)
617
625
618 $ cp -r revert-ref revert-parent-explicit
626 $ cp -r revert-ref revert-parent-explicit
619 $ cd revert-parent-explicit
627 $ cd revert-parent-explicit
620
628
621 revert all files individually and check the output
629 revert all files individually and check the output
622 (output is expected to be different than in the --all case)
630 (output is expected to be different than in the --all case)
623
631
624 $ for file in `python ../gen-revert-cases.py filelist`; do
632 $ for file in `python ../gen-revert-cases.py filelist`; do
625 > echo '### revert for:' $file;
633 > echo '### revert for:' $file;
626 > hg revert $file;
634 > hg revert $file;
627 > echo
635 > echo
628 > done
636 > done
629 ### revert for: added_clean
637 ### revert for: added_clean
630 no changes needed to added_clean
638 no changes needed to added_clean
631
639
640 ### revert for: clean_clean
641 no changes needed to clean_clean
642
632 ### revert for: modified_clean
643 ### revert for: modified_clean
633 no changes needed to modified_clean
644 no changes needed to modified_clean
634
645
635
646
636 check resulting directory againt the --all run
647 check resulting directory againt the --all run
637 (There should be no difference)
648 (There should be no difference)
638
649
639 $ python ../dircontent.py > ../content-parent-explicit.txt
650 $ python ../dircontent.py > ../content-parent-explicit.txt
640 $ cd ..
651 $ cd ..
641 $ diff -U 0 -- content-parent-all.txt content-parent-explicit.txt | grep _
652 $ diff -U 0 -- content-parent-all.txt content-parent-explicit.txt | grep _
642 [1]
653 [1]
643
654
644 Test revert to "base" content with explicit file name
655 Test revert to "base" content with explicit file name
645 -----------------------------------------------------
656 -----------------------------------------------------
646
657
647 (setup from reference repo)
658 (setup from reference repo)
648
659
649 $ cp -r revert-ref revert-base-explicit
660 $ cp -r revert-ref revert-base-explicit
650 $ cd revert-base-explicit
661 $ cd revert-base-explicit
651
662
652 revert all files individually and check the output
663 revert all files individually and check the output
653 (output is expected to be different than in the --all case)
664 (output is expected to be different than in the --all case)
654
665
666 Misbehavior:
667
668 - fails to report no change to revert for
669 |
670 | - clean_clean
671
655 $ for file in `python ../gen-revert-cases.py filelist`; do
672 $ for file in `python ../gen-revert-cases.py filelist`; do
656 > echo '### revert for:' $file;
673 > echo '### revert for:' $file;
657 > hg revert $file --rev 'desc(base)';
674 > hg revert $file --rev 'desc(base)';
658 > echo
675 > echo
659 > done
676 > done
660 ### revert for: added_clean
677 ### revert for: added_clean
661
678
679 ### revert for: clean_clean
680
662 ### revert for: modified_clean
681 ### revert for: modified_clean
663
682
664
683
665 check resulting directory againt the --all run
684 check resulting directory againt the --all run
666 (There should be no difference)
685 (There should be no difference)
667
686
668 $ python ../dircontent.py > ../content-base-explicit.txt
687 $ python ../dircontent.py > ../content-base-explicit.txt
669 $ cd ..
688 $ cd ..
670 $ diff -U 0 -- content-base-all.txt content-base-explicit.txt | grep _
689 $ diff -U 0 -- content-base-all.txt content-base-explicit.txt | grep _
671 [1]
690 [1]
General Comments 0
You need to be logged in to leave comments. Login now