Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 20765:f042d4b263f4 stable
localrepo: save manually edited commit message as soon as possible
Before this patch, "localrepository.commit()" invokes specified
"editor" to edit commit message manually, and saves it after checking
sub-repositories.
This may lose manually edited commit message, if unexpected exception
is raised while checking (or commiting recursively) sub-repositories.
This patch saves manually edited commit message as soon as possible.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 19 Mar 2014 01:07:41 +0900 |
parents | a959f7167077 |
children | efbf15979538 |
comparison
equal
deleted
inserted
replaced
20700:b0153cb8b64e | 20765:f042d4b263f4 |
---|---|
1268 | 1268 |
1269 if editor: | 1269 if editor: |
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): |
1276 sub = wctx.sub(s) | 1281 sub = wctx.sub(s) |
1277 self.ui.status(_('committing subrepository %s\n') % | 1282 self.ui.status(_('committing subrepository %s\n') % |
1278 subrepo.subrelpath(sub)) | 1283 subrepo.subrelpath(sub)) |
1279 sr = sub.commit(cctx._text, user, date) | 1284 sr = sub.commit(cctx._text, user, date) |
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 | |
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 | 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: |
1291 self.hook("precommit", throw=True, parent1=hookp1, | 1291 self.hook("precommit", throw=True, parent1=hookp1, |