Mercurial > hg-stable
changeset 7400:409a9b442308
mq: use atomictempfiles during patch refresh
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sun, 23 Nov 2008 16:07:47 -0800 |
parents | e71bda2d2087 |
children | 41e87b4d0c9d |
files | hgext/mq.py |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Sat Nov 22 14:04:42 2008 -0800 +++ b/hgext/mq.py Sun Nov 23 16:07:47 2008 -0800 @@ -1093,7 +1093,7 @@ patchparent = self.qparents(repo, top) ph = self.readheaders(patchfn) - patchf = self.opener(patchfn, 'r+') + patchf = self.opener(patchfn, 'r') # if the patch was a git patch, refresh it as a git patch for line in patchf: @@ -1108,6 +1108,9 @@ if newdate: ph.setdate(newdate) + # only commit new patch when write is complete + patchf = self.opener(patchfn, 'w', atomictemp=True) + patchf.seek(0) patchf.truncate() @@ -1185,7 +1188,7 @@ changes=c, opts=self.diffopts()) for chunk in chunks: patchf.write(chunk) - patchf.close() + patchf.rename() repo.dirstate.setparents(*cparents) copies = {} @@ -1246,7 +1249,7 @@ self.removeundo(repo) else: self.printdiff(repo, patchparent, fp=patchf) - patchf.close() + patchf.rename() added = repo.status()[1] for a in added: f = repo.wjoin(a)