Show More
@@ -201,7 +201,8 b' def setupwrapcolorwrite(ui):' | |||
|
201 | 201 | setattr(ui, 'write', wrap) |
|
202 | 202 | return oldwrite |
|
203 | 203 | |
|
204 |
def filterchunks(ui, originalhunks, usecurses, testfile, |
|
|
204 | def filterchunks(ui, originalhunks, usecurses, testfile, match, | |
|
205 | operation=None): | |
|
205 | 206 | try: |
|
206 | 207 | if usecurses: |
|
207 | 208 | if testfile: |
@@ -216,9 +217,9 b' def filterchunks(ui, originalhunks, usec' | |||
|
216 | 217 | ui.warn('%s\n' % e.message) |
|
217 | 218 | ui.warn(_('falling back to text mode\n')) |
|
218 | 219 | |
|
219 | return patch.filterpatch(ui, originalhunks, operation) | |
|
220 | ||
|
221 | def recordfilter(ui, originalhunks, operation=None): | |
|
220 | return patch.filterpatch(ui, originalhunks, match, operation) | |
|
221 | ||
|
222 | def recordfilter(ui, originalhunks, match, operation=None): | |
|
222 | 223 | """ Prompts the user to filter the originalhunks and return a list of |
|
223 | 224 | selected hunks. |
|
224 | 225 | *operation* is used for to build ui messages to indicate the user what |
@@ -230,7 +231,7 b' def recordfilter(ui, originalhunks, oper' | |||
|
230 | 231 | oldwrite = setupwrapcolorwrite(ui) |
|
231 | 232 | try: |
|
232 | 233 | newchunks, newopts = filterchunks(ui, originalhunks, usecurses, |
|
233 | testfile, operation) | |
|
234 | testfile, match, operation) | |
|
234 | 235 | finally: |
|
235 | 236 | ui.write = oldwrite |
|
236 | 237 | return newchunks, newopts |
@@ -312,10 +313,11 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||
|
312 | 313 | diffopts.showfunc = True |
|
313 | 314 | originaldiff = patch.diff(repo, changes=status, opts=diffopts) |
|
314 | 315 | originalchunks = patch.parsepatch(originaldiff) |
|
316 | match = scmutil.match(repo[None], pats) | |
|
315 | 317 | |
|
316 | 318 | # 1. filter patch, since we are intending to apply subset of it |
|
317 | 319 | try: |
|
318 | chunks, newopts = filterfn(ui, originalchunks) | |
|
320 | chunks, newopts = filterfn(ui, originalchunks, match) | |
|
319 | 321 | except error.PatchError as err: |
|
320 | 322 | raise error.Abort(_('error parsing patch: %s') % err) |
|
321 | 323 | opts.update(newopts) |
@@ -3081,8 +3083,9 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
3081 | 3083 | prefetch(repo, [ctx.rev()], |
|
3082 | 3084 | matchfiles(repo, |
|
3083 | 3085 | [f for sublist in oplist for f in sublist])) |
|
3086 | match = scmutil.match(repo[None], pats) | |
|
3084 | 3087 | _performrevert(repo, parents, ctx, names, uipathfn, actions, |
|
3085 | interactive, tobackup) | |
|
3088 | match, interactive, tobackup) | |
|
3086 | 3089 | |
|
3087 | 3090 | if targetsubs: |
|
3088 | 3091 | # Revert the subrepos on the revert list |
@@ -3095,7 +3098,7 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
3095 | 3098 | % (sub, short(ctx.node()))) |
|
3096 | 3099 | |
|
3097 | 3100 | def _performrevert(repo, parents, ctx, names, uipathfn, actions, |
|
3098 | interactive=False, tobackup=None): | |
|
3101 | match, interactive=False, tobackup=None): | |
|
3099 | 3102 | """function that actually perform all the actions computed for revert |
|
3100 | 3103 | |
|
3101 | 3104 | This is an independent function to let extension to plug in and react to |
@@ -3191,7 +3194,7 b' def _performrevert(repo, parents, ctx, n' | |||
|
3191 | 3194 | |
|
3192 | 3195 | try: |
|
3193 | 3196 | |
|
3194 | chunks, opts = recordfilter(repo.ui, originalchunks, | |
|
3197 | chunks, opts = recordfilter(repo.ui, originalchunks, match, | |
|
3195 | 3198 | operation=operation) |
|
3196 | 3199 | if operation == 'discard': |
|
3197 | 3200 | chunks = patch.reversehunks(chunks) |
@@ -1065,7 +1065,7 b' def getmessages():' | |||
|
1065 | 1065 | } |
|
1066 | 1066 | } |
|
1067 | 1067 | |
|
1068 | def filterpatch(ui, headers, operation=None): | |
|
1068 | def filterpatch(ui, headers, match, operation=None): | |
|
1069 | 1069 | """Interactively filter patch chunks into applied-only chunks""" |
|
1070 | 1070 | messages = getmessages() |
|
1071 | 1071 | |
@@ -1182,8 +1182,12 b' the hunk is left unchanged.' | |||
|
1182 | 1182 | seen.add(hdr) |
|
1183 | 1183 | if skipall is None: |
|
1184 | 1184 | h.pretty(ui) |
|
1185 | files = h.files() | |
|
1185 | 1186 | msg = (_('examine changes to %s?') % |
|
1186 |
_(' and ').join("'%s'" % f for f in |
|
|
1187 | _(' and ').join("'%s'" % f for f in files)) | |
|
1188 | if all(match.exact(f) for f in files): | |
|
1189 | r, skipall, np = True, None, None | |
|
1190 | else: | |
|
1187 | 1191 | r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None) |
|
1188 | 1192 | if not r: |
|
1189 | 1193 | continue |
@@ -26,10 +26,8 b' Select no files' | |||
|
26 | 26 | > EOF |
|
27 | 27 | diff --git a/empty-rw b/empty-rw |
|
28 | 28 | new file mode 100644 |
|
29 | examine changes to 'empty-rw'? [Ynesfdaq?] n | |
|
30 | ||
|
31 | no changes to record | |
|
32 | [1] | |
|
29 | abort: empty commit message | |
|
30 | [255] | |
|
33 | 31 | |
|
34 | 32 | $ hg tip -p |
|
35 | 33 | changeset: -1:000000000000 |
@@ -47,8 +45,6 b' Select files but no hunks' | |||
|
47 | 45 | > EOF |
|
48 | 46 | diff --git a/empty-rw b/empty-rw |
|
49 | 47 | new file mode 100644 |
|
50 | examine changes to 'empty-rw'? [Ynesfdaq?] y | |
|
51 | ||
|
52 | 48 | abort: empty commit message |
|
53 | 49 | [255] |
|
54 | 50 | |
@@ -72,12 +68,9 b' Record empty file' | |||
|
72 | 68 | |
|
73 | 69 | $ hg commit -i -d '0 0' -m empty empty-rw<<EOF |
|
74 | 70 | > y |
|
75 | > y | |
|
76 | 71 | > EOF |
|
77 | 72 | diff --git a/empty-rw b/empty-rw |
|
78 | 73 | new file mode 100644 |
|
79 | examine changes to 'empty-rw'? [Ynesfdaq?] y | |
|
80 | ||
|
81 | 74 | |
|
82 | 75 | $ hg tip -p |
|
83 | 76 | changeset: 0:c0708cf4e46e |
@@ -249,8 +242,6 b' Add plain file' | |||
|
249 | 242 | > EOF |
|
250 | 243 | diff --git a/plain b/plain |
|
251 | 244 | new file mode 100644 |
|
252 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
253 | ||
|
254 | 245 | @@ -0,0 +1,10 @@ |
|
255 | 246 | +1 |
|
256 | 247 | +2 |
@@ -306,8 +297,6 b' Modify end of plain file, also test that' | |||
|
306 | 297 | > EOF |
|
307 | 298 | diff --git a/plain b/plain |
|
308 | 299 | 1 hunks, 1 lines changed |
|
309 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
310 | ||
|
311 | 300 | @@ -8,3 +8,4 @@ 7 |
|
312 | 301 | 8 |
|
313 | 302 | 9 |
@@ -325,8 +314,6 b' Modify end of plain file, no EOL' | |||
|
325 | 314 | > EOF |
|
326 | 315 | diff --git a/plain b/plain |
|
327 | 316 | 1 hunks, 1 lines changed |
|
328 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
329 | ||
|
330 | 317 | @@ -9,3 +9,4 @@ 8 |
|
331 | 318 | 9 |
|
332 | 319 | 10 |
@@ -467,8 +454,6 b' Modify end of plain file, add EOL' | |||
|
467 | 454 | > EOF |
|
468 | 455 | diff --git a/plain b/plain |
|
469 | 456 | 1 hunks, 1 lines changed |
|
470 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
471 | ||
|
472 | 457 | @@ -9,4 +9,4 @@ 8 |
|
473 | 458 | 9 |
|
474 | 459 | 10 |
@@ -480,8 +465,6 b' Modify end of plain file, add EOL' | |||
|
480 | 465 | |
|
481 | 466 | diff --git a/plain2 b/plain2 |
|
482 | 467 | new file mode 100644 |
|
483 | examine changes to 'plain2'? [Ynesfdaq?] y | |
|
484 | ||
|
485 | 468 | @@ -0,0 +1,1 @@ |
|
486 | 469 | +1 |
|
487 | 470 | record change 2/2 to 'plain2'? [Ynesfdaq?] y |
@@ -504,8 +487,6 b' changes numbering' | |||
|
504 | 487 | > EOF |
|
505 | 488 | diff --git a/plain b/plain |
|
506 | 489 | 2 hunks, 3 lines changed |
|
507 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
508 | ||
|
509 | 490 | @@ -1,4 +1,4 @@ |
|
510 | 491 | -1 |
|
511 | 492 | +2 |
@@ -524,8 +505,6 b' changes numbering' | |||
|
524 | 505 | |
|
525 | 506 | diff --git a/plain2 b/plain2 |
|
526 | 507 | 1 hunks, 1 lines changed |
|
527 | examine changes to 'plain2'? [Ynesfdaq?] y | |
|
528 | ||
|
529 | 508 | @@ -1,1 +1,2 @@ |
|
530 | 509 | 1 |
|
531 | 510 | +2 |
@@ -572,14 +551,11 b' Trim beginning, modify end' | |||
|
572 | 551 | Record end |
|
573 | 552 | |
|
574 | 553 | $ hg commit -i -d '11 0' -m end-only plain <<EOF |
|
575 | > y | |
|
576 | 554 | > n |
|
577 | 555 | > y |
|
578 | 556 | > EOF |
|
579 | 557 | diff --git a/plain b/plain |
|
580 | 558 | 2 hunks, 4 lines changed |
|
581 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
582 | ||
|
583 | 559 | @@ -1,9 +1,6 @@ |
|
584 | 560 | -2 |
|
585 | 561 | -2 |
@@ -630,8 +606,6 b' Record beginning' | |||
|
630 | 606 | > EOF |
|
631 | 607 | diff --git a/plain b/plain |
|
632 | 608 | 1 hunks, 3 lines changed |
|
633 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
634 | ||
|
635 | 609 | @@ -1,6 +1,3 @@ |
|
636 | 610 | -2 |
|
637 | 611 | -2 |
@@ -671,14 +645,11 b' Add to beginning, trim from end' | |||
|
671 | 645 | Record end |
|
672 | 646 | |
|
673 | 647 | $ hg commit -i --traceback -d '13 0' -m end-again plain<<EOF |
|
674 | > y | |
|
675 | 648 | > n |
|
676 | 649 | > y |
|
677 | 650 | > EOF |
|
678 | 651 | diff --git a/plain b/plain |
|
679 | 652 | 2 hunks, 4 lines changed |
|
680 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
681 | ||
|
682 | 653 | @@ -1,6 +1,9 @@ |
|
683 | 654 | +1 |
|
684 | 655 | +2 |
@@ -714,13 +685,10 b' Record beginning, middle, and test that ' | |||
|
714 | 685 | $ hg commit -i --config diff.noprefix=True -d '14 0' -m middle-only plain <<EOF |
|
715 | 686 | > y |
|
716 | 687 | > y |
|
717 | > y | |
|
718 | 688 | > n |
|
719 | 689 | > EOF |
|
720 | 690 | diff --git a/plain b/plain |
|
721 | 691 | 3 hunks, 7 lines changed |
|
722 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
723 | ||
|
724 | 692 | @@ -1,2 +1,5 @@ |
|
725 | 693 | +1 |
|
726 | 694 | +2 |
@@ -781,8 +749,6 b' Record end' | |||
|
781 | 749 | > EOF |
|
782 | 750 | diff --git a/plain b/plain |
|
783 | 751 | 1 hunks, 2 lines changed |
|
784 | examine changes to 'plain'? [Ynesfdaq?] y | |
|
785 | ||
|
786 | 752 | @@ -9,3 +9,5 @@ 6 |
|
787 | 753 | 7 |
|
788 | 754 | 8 |
@@ -823,8 +789,6 b' Record end' | |||
|
823 | 789 | > EOF |
|
824 | 790 | diff --git a/subdir/a b/subdir/a |
|
825 | 791 | 1 hunks, 1 lines changed |
|
826 | examine changes to 'subdir/a'? [Ynesfdaq?] y | |
|
827 | ||
|
828 | 792 | @@ -1,1 +1,2 @@ |
|
829 | 793 | a |
|
830 | 794 | +a |
@@ -879,6 +843,35 b' Help, quit' | |||
|
879 | 843 | abort: user quit |
|
880 | 844 | [255] |
|
881 | 845 | |
|
846 | Patterns | |
|
847 | ||
|
848 | $ hg commit -i 'glob:f*' << EOF | |
|
849 | > y | |
|
850 | > n | |
|
851 | > y | |
|
852 | > n | |
|
853 | > EOF | |
|
854 | diff --git a/subdir/f1 b/subdir/f1 | |
|
855 | 1 hunks, 1 lines changed | |
|
856 | examine changes to 'subdir/f1'? [Ynesfdaq?] y | |
|
857 | ||
|
858 | @@ -1,1 +1,2 @@ | |
|
859 | a | |
|
860 | +a | |
|
861 | record change 1/2 to 'subdir/f1'? [Ynesfdaq?] n | |
|
862 | ||
|
863 | diff --git a/subdir/f2 b/subdir/f2 | |
|
864 | 1 hunks, 1 lines changed | |
|
865 | examine changes to 'subdir/f2'? [Ynesfdaq?] y | |
|
866 | ||
|
867 | @@ -1,1 +1,2 @@ | |
|
868 | b | |
|
869 | +b | |
|
870 | record change 2/2 to 'subdir/f2'? [Ynesfdaq?] n | |
|
871 | ||
|
872 | no changes to record | |
|
873 | [1] | |
|
874 | ||
|
882 | 875 | #if gettext |
|
883 | 876 | |
|
884 | 877 | Test translated help message |
@@ -157,14 +157,11 b' record' | |||
|
157 | 157 | $ chmod +x a |
|
158 | 158 | $ hg record -m moda a <<EOF |
|
159 | 159 | > y |
|
160 | > y | |
|
161 | 160 | > EOF |
|
162 | 161 | \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
|
163 | 162 | \x1b[0;36;1mold mode 100644\x1b[0m (esc) |
|
164 | 163 | \x1b[0;36;1mnew mode 100755\x1b[0m (esc) |
|
165 | 164 | 1 hunks, 1 lines changed |
|
166 | \x1b[0;33mexamine changes to 'a'? [Ynesfdaq?]\x1b[0m y (esc) | |
|
167 | ||
|
168 | 165 | \x1b[0;35m@@ -2,7 +2,7 @@ c\x1b[0m (esc) |
|
169 | 166 | c |
|
170 | 167 | a |
@@ -383,13 +383,10 b' record chunk' | |||
|
383 | 383 | >>> open('a', 'wb').writelines(lines) |
|
384 | 384 | $ hg record -d '10 1' -m rectest a<<EOF |
|
385 | 385 | > y |
|
386 | > y | |
|
387 | 386 | > n |
|
388 | 387 | > EOF |
|
389 | 388 | diff --git a/a b/a |
|
390 | 389 | 2 hunks, 2 lines changed |
|
391 | examine changes to 'a'? [Ynesfdaq?] y | |
|
392 | ||
|
393 | 390 | @@ -1,3 +1,4 @@ |
|
394 | 391 | expand $Id$ |
|
395 | 392 | +foo |
@@ -448,8 +445,6 b' Record all chunks in file a' | |||
|
448 | 445 | > EOF |
|
449 | 446 | diff --git a/a b/a |
|
450 | 447 | 2 hunks, 2 lines changed |
|
451 | examine changes to 'a'? [Ynesfdaq?] y | |
|
452 | ||
|
453 | 448 | @@ -1,3 +1,4 @@ |
|
454 | 449 | expand $Id$ |
|
455 | 450 | +foo |
@@ -519,8 +514,6 b' record added file alone' | |||
|
519 | 514 | > EOF |
|
520 | 515 | diff --git a/r b/r |
|
521 | 516 | new file mode 100644 |
|
522 | examine changes to 'r'? [Ynesfdaq?] y | |
|
523 | ||
|
524 | 517 | @@ -0,0 +1,1 @@ |
|
525 | 518 | +$Id$ |
|
526 | 519 | record this change to 'r'? [Ynesfdaq?] y |
@@ -76,10 +76,8 b' Select no files' | |||
|
76 | 76 | > EOF |
|
77 | 77 | diff --git a/empty-rw b/empty-rw |
|
78 | 78 | new file mode 100644 |
|
79 | examine changes to 'empty-rw'? [Ynesfdaq?] n | |
|
80 | ||
|
81 | no changes to record | |
|
82 | [1] | |
|
79 | abort: empty commit message | |
|
80 | [255] | |
|
83 | 81 | |
|
84 | 82 | $ hg tip -p |
|
85 | 83 | changeset: -1:000000000000 |
@@ -149,11 +149,9 b' Test that --interactive lift the need fo' | |||
|
149 | 149 | g |
|
150 | 150 | |
|
151 | 151 | Test that a noop revert doesn't do an unnecessary backup |
|
152 |
$ (echo |
|
|
152 | $ (echo n) | hg revert -i -r 2 folder1/g | |
|
153 | 153 | diff --git a/folder1/g b/folder1/g |
|
154 | 154 | 1 hunks, 1 lines changed |
|
155 | examine changes to 'folder1/g'? [Ynesfdaq?] y | |
|
156 | ||
|
157 | 155 | @@ -3,4 +3,3 @@ |
|
158 | 156 | 3 |
|
159 | 157 | 4 |
@@ -165,11 +163,9 b" Test that a noop revert doesn't do an un" | |||
|
165 | 163 | g |
|
166 | 164 | |
|
167 | 165 | Test --no-backup |
|
168 |
$ (echo y |
|
|
166 | $ (echo y) | hg revert -i -C -r 2 folder1/g | |
|
169 | 167 | diff --git a/folder1/g b/folder1/g |
|
170 | 168 | 1 hunks, 1 lines changed |
|
171 | examine changes to 'folder1/g'? [Ynesfdaq?] y | |
|
172 | ||
|
173 | 169 | @@ -3,4 +3,3 @@ |
|
174 | 170 | 3 |
|
175 | 171 | 4 |
@@ -270,7 +266,6 b' Test --no-backup' | |||
|
270 | 266 | M f |
|
271 | 267 | M folder1/g |
|
272 | 268 | $ hg revert --interactive f << EOF |
|
273 | > y | |
|
274 | 269 | > ? |
|
275 | 270 | > y |
|
276 | 271 | > n |
@@ -278,8 +273,6 b' Test --no-backup' | |||
|
278 | 273 | > EOF |
|
279 | 274 | diff --git a/f b/f |
|
280 | 275 | 2 hunks, 2 lines changed |
|
281 | examine changes to 'f'? [Ynesfdaq?] y | |
|
282 | ||
|
283 | 276 | @@ -1,6 +1,5 @@ |
|
284 | 277 | -a |
|
285 | 278 | 1 |
@@ -327,6 +320,25 b' Test --no-backup' | |||
|
327 | 320 | 4 |
|
328 | 321 | 5 |
|
329 | 322 | $ rm f.orig |
|
323 | ||
|
324 | Patterns | |
|
325 | ||
|
326 | $ hg revert -i 'glob:f*' << EOF | |
|
327 | > y | |
|
328 | > n | |
|
329 | > EOF | |
|
330 | diff --git a/f b/f | |
|
331 | 1 hunks, 1 lines changed | |
|
332 | examine changes to 'f'? [Ynesfdaq?] y | |
|
333 | ||
|
334 | @@ -4,4 +4,3 @@ | |
|
335 | 3 | |
|
336 | 4 | |
|
337 | 5 | |
|
338 | -b | |
|
339 | discard this change to 'f'? [Ynesfdaq?] n | |
|
340 | ||
|
341 | ||
|
330 | 342 |
$ |
|
331 | 343 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
332 | 344 |
General Comments 0
You need to be logged in to leave comments.
Login now