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