##// END OF EJS Templates
localrepo: add savecommitmessage() to write last-message.txt
Patrick Mezard -
r14529:e7a18148 default
parent child Browse files
Show More
@@ -2273,9 +2273,7 b' def refresh(ui, repo, *pats, **opts):'
2273 ph = patchheader(q.join(patch), q.plainmode)
2273 ph = patchheader(q.join(patch), q.plainmode)
2274 message = ui.edit('\n'.join(ph.message), ph.user or ui.username())
2274 message = ui.edit('\n'.join(ph.message), ph.user or ui.username())
2275 # We don't want to lose the patch message if qrefresh fails (issue2062)
2275 # We don't want to lose the patch message if qrefresh fails (issue2062)
2276 msgfile = repo.opener('last-message.txt', 'wb')
2276 repo.savecommitmessage(message)
2277 msgfile.write(message)
2278 msgfile.close()
2279 setupheaderopts(ui, opts)
2277 setupheaderopts(ui, opts)
2280 ret = q.refresh(repo, pats, msg=message, **opts)
2278 ret = q.refresh(repo, pats, msg=message, **opts)
2281 q.save_dirty()
2279 q.save_dirty()
@@ -3159,7 +3159,7 b' def import_(ui, repo, patch1, *patches, '
3159 raise util.Abort(_('no diffs found'))
3159 raise util.Abort(_('no diffs found'))
3160
3160
3161 if msgs:
3161 if msgs:
3162 repo.opener.write('last-message.txt', '\n* * *\n'.join(msgs))
3162 repo.savecommitmessage('\n* * *\n'.join(msgs))
3163 finally:
3163 finally:
3164 release(lock, wlock)
3164 release(lock, wlock)
3165
3165
@@ -1012,9 +1012,7 b' class localrepository(repo.repository):'
1012 # Save commit message in case this transaction gets rolled back
1012 # Save commit message in case this transaction gets rolled back
1013 # (e.g. by a pretxncommit hook). Leave the content alone on
1013 # (e.g. by a pretxncommit hook). Leave the content alone on
1014 # the assumption that the user will use the same editor again.
1014 # the assumption that the user will use the same editor again.
1015 msgfile = self.opener('last-message.txt', 'wb')
1015 msgfn = self.savecommitmessage(cctx._text)
1016 msgfile.write(cctx._text)
1017 msgfile.close()
1018
1016
1019 p1, p2 = self.dirstate.parents()
1017 p1, p2 = self.dirstate.parents()
1020 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1018 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
@@ -1023,7 +1021,6 b' class localrepository(repo.repository):'
1023 ret = self.commitctx(cctx, True)
1021 ret = self.commitctx(cctx, True)
1024 except:
1022 except:
1025 if edited:
1023 if edited:
1026 msgfn = self.pathto(msgfile.name[len(self.root)+1:])
1027 self.ui.write(
1024 self.ui.write(
1028 _('note: commit message saved in %s\n') % msgfn)
1025 _('note: commit message saved in %s\n') % msgfn)
1029 raise
1026 raise
@@ -1954,6 +1951,14 b' class localrepository(repo.repository):'
1954 '''used to test argument passing over the wire'''
1951 '''used to test argument passing over the wire'''
1955 return "%s %s %s %s %s" % (one, two, three, four, five)
1952 return "%s %s %s %s %s" % (one, two, three, four, five)
1956
1953
1954 def savecommitmessage(self, text):
1955 fp = self.opener('last-message.txt', 'wb')
1956 try:
1957 fp.write(text)
1958 finally:
1959 fp.close()
1960 return self.pathto(fp.name[len(self.root)+1:])
1961
1957 # used to avoid circular references so destructors work
1962 # used to avoid circular references so destructors work
1958 def aftertrans(files):
1963 def aftertrans(files):
1959 renamefiles = [tuple(t) for t in files]
1964 renamefiles = [tuple(t) for t in files]
General Comments 0
You need to be logged in to leave comments. Login now