##// END OF EJS Templates
commit: save commit message so it's not destroyed by rollback....
Greg Ward -
r9934:720f70b7 default
parent child Browse files
Show More
@@ -835,6 +835,15 b' class localrepository(repo.repository):'
835 state[s] = (state[s][0], sr)
835 state[s] = (state[s][0], sr)
836 subrepo.writestate(self, state)
836 subrepo.writestate(self, state)
837
837
838 # Save commit message in case this transaction gets rolled back
839 # (e.g. by a pretxncommit hook). (Save in text mode in case a
840 # Windows user wants to edit it with Notepad. Normalize
841 # trailing whitespace so the file always looks the same --
842 # makes testing easier.)
843 msgfile = self.opener('last-message.txt', 'w')
844 msgfile.write(cctx._text.rstrip() + '\n')
845 msgfile.close()
846
838 ret = self.commitctx(cctx, True)
847 ret = self.commitctx(cctx, True)
839
848
840 # update dirstate and mergestate
849 # update dirstate and mergestate
@@ -50,6 +50,7 b' adding tst.d/foo'
50 .hg/data/tst.d.hg
50 .hg/data/tst.d.hg
51 .hg/data/tst.d.hg/foo.i
51 .hg/data/tst.d.hg/foo.i
52 .hg/dirstate
52 .hg/dirstate
53 .hg/last-message.txt
53 .hg/requires
54 .hg/requires
54 .hg/undo
55 .hg/undo
55 .hg/undo.branch
56 .hg/undo.branch
@@ -59,6 +60,7 b' adding tst.d/Foo'
59 .hg
60 .hg
60 .hg/00changelog.i
61 .hg/00changelog.i
61 .hg/dirstate
62 .hg/dirstate
63 .hg/last-message.txt
62 .hg/requires
64 .hg/requires
63 .hg/store
65 .hg/store
64 .hg/store/00changelog.i
66 .hg/store/00changelog.i
@@ -14,6 +14,7 b' 00770 ./.hg/store/'
14 00700 ./.hg/
14 00700 ./.hg/
15 00600 ./.hg/00changelog.i
15 00600 ./.hg/00changelog.i
16 00660 ./.hg/dirstate
16 00660 ./.hg/dirstate
17 00660 ./.hg/last-message.txt
17 00600 ./.hg/requires
18 00600 ./.hg/requires
18 00770 ./.hg/store/
19 00770 ./.hg/store/
19 00660 ./.hg/store/00changelog.i
20 00660 ./.hg/store/00changelog.i
@@ -15,14 +15,25 b' hg parents'
15 hg status
15 hg status
16
16
17 echo % Test issue 902
17 echo % Test issue 902
18 hg commit -m "test"
18 hg commit -m "test2"
19 hg branch test
19 hg branch test
20 hg rollback
20 hg rollback
21 hg branch
21 hg branch
22
22
23 echo '% Test issue 1635 (commit message saved)'
24 echo '.hg/last-message.txt:'
25 cat .hg/last-message.txt
26
23 echo % Test rollback of hg before issue 902 was fixed
27 echo % Test rollback of hg before issue 902 was fixed
24 hg commit -m "test"
28 hg commit -m "test3"
25 hg branch test
29 hg branch test
26 rm .hg/undo.branch
30 rm .hg/undo.branch
27 hg rollback
31 hg rollback
28 hg branch
32 hg branch
33
34 echo '% rollback by pretxncommit saves commit message (issue 1635)'
35 echo a >> a
36 hg --config hooks.pretxncommit=/bin/false commit -m"precious commit message"
37
38 echo '.hg/last-message.txt:'
39 cat .hg/last-message.txt
@@ -20,8 +20,17 b' A a'
20 marked working directory as branch test
20 marked working directory as branch test
21 rolling back last transaction
21 rolling back last transaction
22 default
22 default
23 % Test issue 1635 (commit message saved)
24 .hg/last-message.txt:
25 test2
23 % Test rollback of hg before issue 902 was fixed
26 % Test rollback of hg before issue 902 was fixed
24 marked working directory as branch test
27 marked working directory as branch test
25 rolling back last transaction
28 rolling back last transaction
26 Named branch could not be reset, current branch still is: test
29 Named branch could not be reset, current branch still is: test
27 test
30 test
31 % rollback by pretxncommit saves commit message (issue 1635)
32 transaction abort!
33 rollback completed
34 abort: pretxncommit hook exited with status 1
35 .hg/last-message.txt:
36 precious commit message
General Comments 0
You need to be logged in to leave comments. Login now