Show More
@@ -1270,6 +1270,11 class localrepository(object): | |||||
1270 | cctx._text = editor(self, cctx, subs) |
|
1270 | cctx._text = editor(self, cctx, subs) | |
1271 | edited = (text != cctx._text) |
|
1271 | edited = (text != cctx._text) | |
1272 |
|
1272 | |||
|
1273 | # Save commit message in case this transaction gets rolled back | |||
|
1274 | # (e.g. by a pretxncommit hook). Leave the content alone on | |||
|
1275 | # the assumption that the user will use the same editor again. | |||
|
1276 | msgfn = self.savecommitmessage(cctx._text) | |||
|
1277 | ||||
1273 | # commit subs and write new state |
|
1278 | # commit subs and write new state | |
1274 | if subs: |
|
1279 | if subs: | |
1275 | for s in sorted(commitsubs): |
|
1280 | for s in sorted(commitsubs): | |
@@ -1280,11 +1285,6 class localrepository(object): | |||||
1280 | newstate[s] = (newstate[s][0], sr) |
|
1285 | newstate[s] = (newstate[s][0], sr) | |
1281 | subrepo.writestate(self, newstate) |
|
1286 | subrepo.writestate(self, newstate) | |
1282 |
|
1287 | |||
1283 | # Save commit message in case this transaction gets rolled back |
|
|||
1284 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
|||
1285 | # the assumption that the user will use the same editor again. |
|
|||
1286 | msgfn = self.savecommitmessage(cctx._text) |
|
|||
1287 |
|
||||
1288 | p1, p2 = self.dirstate.parents() |
|
1288 | p1, p2 = self.dirstate.parents() | |
1289 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
1289 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') | |
1290 | try: |
|
1290 | try: |
@@ -284,6 +284,52 test commit message content | |||||
284 | HG: removed removed |
|
284 | HG: removed removed | |
285 | abort: empty commit message |
|
285 | abort: empty commit message | |
286 | [255] |
|
286 | [255] | |
|
287 | ||||
|
288 | test saving last-message.txt | |||
|
289 | ||||
|
290 | $ hg init sub | |||
|
291 | $ echo a > sub/a | |||
|
292 | $ hg -R sub add sub/a | |||
|
293 | $ cat > sub/.hg/hgrc <<EOF | |||
|
294 | > [hooks] | |||
|
295 | > precommit.test-saving-last-message = false | |||
|
296 | > EOF | |||
|
297 | ||||
|
298 | $ echo 'sub = sub' > .hgsub | |||
|
299 | $ hg add .hgsub | |||
|
300 | ||||
|
301 | $ cat > $TESTDIR/editor.sh <<EOF | |||
|
302 | > echo "==== before editing:" | |||
|
303 | > cat \$1 | |||
|
304 | > echo "====" | |||
|
305 | > echo "test saving last-message.txt" >> \$1 | |||
|
306 | > EOF | |||
|
307 | ||||
|
308 | $ rm -f .hg/last-message.txt | |||
|
309 | $ HGEDITOR="sh $TESTDIR/editor.sh" hg commit -S -q | |||
|
310 | ==== before editing: | |||
|
311 | ||||
|
312 | ||||
|
313 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |||
|
314 | HG: Leave message empty to abort commit. | |||
|
315 | HG: -- | |||
|
316 | HG: user: test | |||
|
317 | HG: branch 'default' | |||
|
318 | HG: bookmark 'currentbookmark' | |||
|
319 | HG: subrepo sub | |||
|
320 | HG: added .hgsub | |||
|
321 | HG: added added | |||
|
322 | HG: changed .hgsubstate | |||
|
323 | HG: changed changed | |||
|
324 | HG: removed removed | |||
|
325 | ==== | |||
|
326 | abort: precommit.test-saving-last-message hook exited with status 1 (in subrepo sub) | |||
|
327 | [255] | |||
|
328 | $ cat .hg/last-message.txt | |||
|
329 | ||||
|
330 | ||||
|
331 | test saving last-message.txt | |||
|
332 | ||||
287 | $ cd .. |
|
333 | $ cd .. | |
288 |
|
334 | |||
289 |
|
335 |
General Comments 0
You need to be logged in to leave comments.
Login now