##// END OF EJS Templates
rebase: adds storing collapse message (issue4792)...
liscju -
r28185:c7e89486 default
parent child Browse files
Show More
@@ -263,9 +263,11 b' def rebase(ui, repo, **opts):'
263 263 try:
264 264 (originalwd, target, state, skipped, collapsef, keepf,
265 265 keepbranchesf, external, activebookmark) = restorestatus(repo)
266 collapsemsg = restorecollapsemsg(repo)
266 267 except error.RepoLookupError:
267 268 if abortf:
268 269 clearstatus(repo)
270 clearcollapsemsg(repo)
269 271 repo.ui.warn(_('rebase aborted (no revision is removed,'
270 272 ' only broken state is cleared)\n'))
271 273 return 0
@@ -388,6 +390,7 b' def rebase(ui, repo, **opts):'
388 390 targetancestors)
389 391 storestatus(repo, originalwd, target, state, collapsef, keepf,
390 392 keepbranchesf, external, activebookmark)
393 storecollapsemsg(repo, collapsemsg)
391 394 if len(repo[None].parents()) == 2:
392 395 repo.ui.debug('resuming interrupted rebase\n')
393 396 else:
@@ -509,6 +512,7 b' def rebase(ui, repo, **opts):'
509 512 # active bookmark was divergent one and has been deleted
510 513 activebookmark = None
511 514 clearstatus(repo)
515 clearcollapsemsg(repo)
512 516
513 517 ui.note(_("rebase completed\n"))
514 518 util.unlinkpath(repo.sjoin('undo'), ignoremissing=True)
@@ -846,6 +850,29 b' def updatebookmarks(repo, targetnode, ns'
846 850 bookmarks.deletedivergent(repo, [targetnode], k)
847 851 marks.recordchange(tr)
848 852
853 def storecollapsemsg(repo, collapsemsg):
854 'Store the collapse message to allow recovery'
855 collapsemsg = collapsemsg or ''
856 f = repo.vfs("last-message.txt", "w")
857 f.write("%s\n" % collapsemsg)
858 f.close()
859
860 def clearcollapsemsg(repo):
861 'Remove collapse message file'
862 util.unlinkpath(repo.join("last-message.txt"), ignoremissing=True)
863
864 def restorecollapsemsg(repo):
865 'Restore previously stored collapse message'
866 try:
867 f = repo.vfs("last-message.txt")
868 collapsemsg = f.readline().strip()
869 f.close()
870 except IOError as err:
871 if err.errno != errno.ENOENT:
872 raise
873 raise error.Abort(_('no rebase in progress'))
874 return collapsemsg
875
849 876 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
850 877 external, activebookmark):
851 878 'Store the current status to allow recovery'
@@ -1005,6 +1032,7 b' def abort(repo, originalwd, target, stat'
1005 1032
1006 1033 finally:
1007 1034 clearstatus(repo)
1035 clearcollapsemsg(repo)
1008 1036 repo.ui.warn(_('rebase aborted\n'))
1009 1037 return 0
1010 1038
@@ -804,3 +804,52 b' Test collapsing changes that add then re'
804 804 base
805 805
806 806 $ cd ..
807
808 Test that rebase --collapse will remember message after
809 running into merge conflict and invoking rebase --continue.
810
811 $ hg init collapse_remember_message
812 $ cd collapse_remember_message
813 $ touch a
814 $ hg add a
815 $ hg commit -m "a"
816 $ echo "a-default" > a
817 $ hg commit -m "a-default"
818 $ hg update -r 0
819 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
820 $ hg branch dev
821 marked working directory as branch dev
822 (branches are permanent and global, did you want a bookmark?)
823 $ echo "a-dev" > a
824 $ hg commit -m "a-dev"
825 $ hg rebase --collapse -m "a-default-dev" -d 1
826 rebasing 2:b8d8db2b242d "a-dev" (tip)
827 merging a
828 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
829 unresolved conflicts (see hg resolve, then hg rebase --continue)
830 [1]
831 $ rm a.orig
832 $ hg resolve --mark a
833 (no more unresolved files)
834 continue: hg rebase --continue
835 $ hg rebase --continue
836 rebasing 2:b8d8db2b242d "a-dev" (tip)
837 saved backup bundle to $TESTTMP/collapse_remember_message/.hg/strip-backup/b8d8db2b242d-f474c19a-backup.hg (glob)
838 $ hg log
839 changeset: 2:12bb766dceb1
840 tag: tip
841 user: test
842 date: Thu Jan 01 00:00:00 1970 +0000
843 summary: a-default-dev
844
845 changeset: 1:3c8db56a44bc
846 user: test
847 date: Thu Jan 01 00:00:00 1970 +0000
848 summary: a-default
849
850 changeset: 0:3903775176ed
851 user: test
852 date: Thu Jan 01 00:00:00 1970 +0000
853 summary: a
854
855 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now