##// END OF EJS Templates
rebase: add --confirm option...
Sushil khanchi -
r38689:572dff5c @78 default
parent child Browse files
Show More
@@ -677,7 +677,7 b' class rebaseruntime(object):'
677 ('a', 'abort', False, _('abort an interrupted rebase')),
677 ('a', 'abort', False, _('abort an interrupted rebase')),
678 ('', 'auto-orphans', '', _('automatically rebase orphan revisions '
678 ('', 'auto-orphans', '', _('automatically rebase orphan revisions '
679 'in the specified revset (EXPERIMENTAL)')),
679 'in the specified revset (EXPERIMENTAL)')),
680 ] + cmdutil.dryrunopts + cmdutil.formatteropts,
680 ] + cmdutil.dryrunopts + cmdutil.formatteropts + cmdutil.confirmopts,
681 _('[-s REV | -b REV] [-d REV] [OPTION]'))
681 _('[-s REV | -b REV] [-d REV] [OPTION]'))
682 def rebase(ui, repo, **opts):
682 def rebase(ui, repo, **opts):
683 """move changeset (and descendants) to a different branch
683 """move changeset (and descendants) to a different branch
@@ -808,6 +808,14 b' def rebase(ui, repo, **opts):'
808 raise error.Abort(_('cannot specify both --dry-run and --abort'))
808 raise error.Abort(_('cannot specify both --dry-run and --abort'))
809 if opts.get('continue'):
809 if opts.get('continue'):
810 raise error.Abort(_('cannot specify both --dry-run and --continue'))
810 raise error.Abort(_('cannot specify both --dry-run and --continue'))
811 if opts.get('confirm'):
812 dryrun = True
813 if opts.get('dry_run'):
814 raise error.Abort(_('cannot specify both --confirm and --dry-run'))
815 if opts.get('abort'):
816 raise error.Abort(_('cannot specify both --confirm and --abort'))
817 if opts.get('continue'):
818 raise error.Abort(_('cannot specify both --confirm and --continue'))
811
819
812 if (opts.get('continue') or opts.get('abort') or
820 if (opts.get('continue') or opts.get('abort') or
813 repo.currenttransaction() is not None):
821 repo.currenttransaction() is not None):
@@ -844,8 +852,14 b' def rebase(ui, repo, **opts):'
844
852
845 def _dryrunrebase(ui, repo, opts):
853 def _dryrunrebase(ui, repo, opts):
846 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts)
854 rbsrt = rebaseruntime(repo, ui, inmemory=True, opts=opts)
847 ui.status(_('starting dry-run rebase; repository will not be changed\n'))
855 confirm = opts.get('confirm')
856 if confirm:
857 ui.status(_('starting rebase...\n'))
858 else:
859 ui.status(_('starting dry-run rebase; repository will not be '
860 'changed\n'))
848 with repo.wlock(), repo.lock():
861 with repo.wlock(), repo.lock():
862 needsabort = True
849 try:
863 try:
850 overrides = {('rebase', 'singletransaction'): True}
864 overrides = {('rebase', 'singletransaction'): True}
851 with ui.configoverride(overrides, 'rebase'):
865 with ui.configoverride(overrides, 'rebase'):
@@ -853,15 +867,35 b' def _dryrunrebase(ui, repo, opts):'
853 leaveunfinished=True)
867 leaveunfinished=True)
854 except error.InMemoryMergeConflictsError:
868 except error.InMemoryMergeConflictsError:
855 ui.status(_('hit a merge conflict\n'))
869 ui.status(_('hit a merge conflict\n'))
870 if confirm:
871 # abort as in-memory merge doesn't support conflict
872 rbsrt._prepareabortorcontinue(isabort=True, backup=False,
873 suppwarns=True)
874 needsabort = False
875 if not ui.promptchoice(_(b'apply changes (yn)?'
876 b'$$ &Yes $$ &No')):
877 _dorebase(ui, repo, opts, inmemory=False)
856 return 1
878 return 1
857 else:
879 else:
858 ui.status(_('dry-run rebase completed successfully; run without '
880 if confirm:
859 '-n/--dry-run to perform this rebase\n'))
881 ui.status(_('rebase completed successfully\n'))
882 if not ui.promptchoice(_(b'apply changes (yn)?'
883 b'$$ &Yes $$ &No')):
884 # finish unfinished rebase
885 rbsrt._finishrebase()
886 else:
887 rbsrt._prepareabortorcontinue(isabort=True, backup=False,
888 suppwarns=True)
889 needsabort = False
890 else:
891 ui.status(_('dry-run rebase completed successfully; run without'
892 ' -n/--dry-run to perform this rebase\n'))
860 return 0
893 return 0
861 finally:
894 finally:
862 # no need to store backup in case of dryrun
895 if needsabort:
863 rbsrt._prepareabortorcontinue(isabort=True, backup=False,
896 # no need to store backup in case of dryrun
864 suppwarns=True)
897 rbsrt._prepareabortorcontinue(isabort=True, backup=False,
898 suppwarns=True)
865
899
866 def _dorebase(ui, repo, opts, inmemory=False):
900 def _dorebase(ui, repo, opts, inmemory=False):
867 rbsrt = rebaseruntime(repo, ui, inmemory, opts)
901 rbsrt = rebaseruntime(repo, ui, inmemory, opts)
@@ -62,6 +62,11 b' dryrunopts = ['
62 _('do not perform actions, just print output')),
62 _('do not perform actions, just print output')),
63 ]
63 ]
64
64
65 confirmopts = [
66 ('', 'confirm', None,
67 _('ask before applying actions')),
68 ]
69
65 remoteopts = [
70 remoteopts = [
66 ('e', 'ssh', '',
71 ('e', 'ssh', '',
67 _('specify ssh command to use'), _('CMD')),
72 _('specify ssh command to use'), _('CMD')),
@@ -4,6 +4,7 b''
4 > amend=
4 > amend=
5 > rebase=
5 > rebase=
6 > debugdrawdag=$TESTDIR/drawdag.py
6 > debugdrawdag=$TESTDIR/drawdag.py
7 > strip=
7 > [rebase]
8 > [rebase]
8 > experimental.inmemory=1
9 > experimental.inmemory=1
9 > [diff]
10 > [diff]
@@ -156,8 +157,8 b' Rebase the working copy parent'
156 o 0: b173517d0057 'a'
157 o 0: b173517d0057 'a'
157
158
158 Test dry-run rebasing
159 Test dry-run rebasing
159 $ hg init skrepo
160 $ hg init repo3
160 $ cd skrepo
161 $ cd repo3
161 $ echo a>a
162 $ echo a>a
162 $ hg ci -Aqma
163 $ hg ci -Aqma
163 $ echo b>b
164 $ echo b>b
@@ -323,3 +324,246 b' Check dryrun working with --collapse whe'
323 merging e
324 merging e
324 hit a merge conflict
325 hit a merge conflict
325 [1]
326 [1]
327
328 ==========================
329 Test for --confirm option|
330 ==========================
331 $ cd ..
332 $ hg clone repo3 repo4 -q
333 $ cd repo4
334 $ hg strip 7 -q
335 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
336 @ 6:baf10c5166d4 test
337 | g
338 |
339 o 5:6343ca3eff20 test
340 | f
341 |
342 | o 4:e860deea161a test
343 | | e
344 | |
345 | o 3:055a42cdd887 test
346 | | d
347 | |
348 | o 2:177f92b77385 test
349 |/ c
350 |
351 o 1:d2ae7f538514 test
352 | b
353 |
354 o 0:cb9a9f314b8b test
355 a
356
357 Check it gives error when both --dryrun and --confirm is used:
358 $ hg rebase -s 2 -d . --confirm --dry-run
359 abort: cannot specify both --confirm and --dry-run
360 [255]
361 $ hg rebase -s 2 -d . --confirm --abort
362 abort: cannot specify both --confirm and --abort
363 [255]
364 $ hg rebase -s 2 -d . --confirm --continue
365 abort: cannot specify both --confirm and --continue
366 [255]
367
368 Test --confirm option when there are no conflicts:
369 $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF
370 > n
371 > EOF
372 starting rebase...
373 rebasing 2:177f92b77385 "c"
374 rebasing 3:055a42cdd887 "d"
375 rebasing 4:e860deea161a "e"
376 rebase completed successfully
377 apply changes (yn)? n
378 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
379 @ 6:baf10c5166d4 test
380 | g
381 |
382 o 5:6343ca3eff20 test
383 | f
384 |
385 | o 4:e860deea161a test
386 | | e
387 | |
388 | o 3:055a42cdd887 test
389 | | d
390 | |
391 | o 2:177f92b77385 test
392 |/ c
393 |
394 o 1:d2ae7f538514 test
395 | b
396 |
397 o 0:cb9a9f314b8b test
398 a
399
400 $ hg rebase -s 2 -d . --keep --config ui.interactive=True --confirm << EOF
401 > y
402 > EOF
403 starting rebase...
404 rebasing 2:177f92b77385 "c"
405 rebasing 3:055a42cdd887 "d"
406 rebasing 4:e860deea161a "e"
407 rebase completed successfully
408 apply changes (yn)? y
409 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
410 o 9:9fd28f55f6dc test
411 | e
412 |
413 o 8:12cbf031f469 test
414 | d
415 |
416 o 7:c83b1da5b1ae test
417 | c
418 |
419 @ 6:baf10c5166d4 test
420 | g
421 |
422 o 5:6343ca3eff20 test
423 | f
424 |
425 | o 4:e860deea161a test
426 | | e
427 | |
428 | o 3:055a42cdd887 test
429 | | d
430 | |
431 | o 2:177f92b77385 test
432 |/ c
433 |
434 o 1:d2ae7f538514 test
435 | b
436 |
437 o 0:cb9a9f314b8b test
438 a
439
440 Test --confirm option when there is a conflict
441 $ hg up tip -q
442 $ echo ee>e
443 $ hg ci --amend -m "conflict with e" -q
444 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
445 @ 9:906d72f66a59 test
446 | conflict with e
447 |
448 o 8:12cbf031f469 test
449 | d
450 |
451 o 7:c83b1da5b1ae test
452 | c
453 |
454 o 6:baf10c5166d4 test
455 | g
456 |
457 o 5:6343ca3eff20 test
458 | f
459 |
460 | o 4:e860deea161a test
461 | | e
462 | |
463 | o 3:055a42cdd887 test
464 | | d
465 | |
466 | o 2:177f92b77385 test
467 |/ c
468 |
469 o 1:d2ae7f538514 test
470 | b
471 |
472 o 0:cb9a9f314b8b test
473 a
474
475 $ hg rebase -s 4 -d . --keep --config ui.interactive=True --confirm << EOF
476 > n
477 > EOF
478 starting rebase...
479 rebasing 4:e860deea161a "e"
480 merging e
481 hit a merge conflict
482 apply changes (yn)? n
483 [1]
484 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
485 @ 9:906d72f66a59 test
486 | conflict with e
487 |
488 o 8:12cbf031f469 test
489 | d
490 |
491 o 7:c83b1da5b1ae test
492 | c
493 |
494 o 6:baf10c5166d4 test
495 | g
496 |
497 o 5:6343ca3eff20 test
498 | f
499 |
500 | o 4:e860deea161a test
501 | | e
502 | |
503 | o 3:055a42cdd887 test
504 | | d
505 | |
506 | o 2:177f92b77385 test
507 |/ c
508 |
509 o 1:d2ae7f538514 test
510 | b
511 |
512 o 0:cb9a9f314b8b test
513 a
514
515
516 $ hg rebase -s 4 -d . --keep --config ui.interactive=True --confirm << EOF
517 > y
518 > EOF
519 starting rebase...
520 rebasing 4:e860deea161a "e"
521 merging e
522 hit a merge conflict
523 apply changes (yn)? y
524 rebasing 4:e860deea161a "e"
525 merging e
526 warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
527 unresolved conflicts (see hg resolve, then hg rebase --continue)
528 [1]
529
530 $ echo e>e
531 $ hg resolve --mark --all
532 (no more unresolved files)
533 continue: hg rebase --continue
534 $ hg rebase --continue
535 rebasing 4:e860deea161a "e"
536 $ hg log -G --template "{rev}:{short(node)} {person(author)}\n{firstline(desc)} {topic}\n\n"
537 o 10:9fa3731dd6df test
538 | e
539 |
540 @ 9:906d72f66a59 test
541 | conflict with e
542 |
543 o 8:12cbf031f469 test
544 | d
545 |
546 o 7:c83b1da5b1ae test
547 | c
548 |
549 o 6:baf10c5166d4 test
550 | g
551 |
552 o 5:6343ca3eff20 test
553 | f
554 |
555 | o 4:e860deea161a test
556 | | e
557 | |
558 | o 3:055a42cdd887 test
559 | | d
560 | |
561 | o 2:177f92b77385 test
562 |/ c
563 |
564 o 1:d2ae7f538514 test
565 | b
566 |
567 o 0:cb9a9f314b8b test
568 a
569
General Comments 0
You need to be logged in to leave comments. Login now