# HG changeset patch # User Patrick Mezard # Date 1262098829 -3600 # Node ID 926c436964b430b6905d1ba0fe606dd0e1485e51 # Parent fa7170d6529f20404853a0e3bb38ef39ba507de9 mq: untangle git patch detection diff -r fa7170d6529f -r 926c436964b4 hgext/mq.py --- a/hgext/mq.py Tue Dec 29 16:00:24 2009 +0100 +++ b/hgext/mq.py Tue Dec 29 16:00:29 2009 +0100 @@ -1159,15 +1159,6 @@ cparents = repo.changelog.parents(top) patchparent = self.qparents(repo, top) ph = patchheader(self.join(patchfn)) - - patchf = self.opener(patchfn, 'r') - - # if the patch was a git patch, refresh it as a git patch - for line in patchf: - if line.startswith('diff --git'): - self.diffopts().git = True - break - if msg: ph.setmessage(msg) if newuser: @@ -1175,12 +1166,17 @@ if newdate: ph.setdate(newdate) + # if the patch was a git patch, refresh it as a git patch + patchf = self.opener(patchfn, 'r') + for line in patchf: + if line.startswith('diff --git'): + self.diffopts().git = True + break + patchf.close() + # only commit new patch when write is complete patchf = self.opener(patchfn, 'w', atomictemp=True) - patchf.seek(0) - patchf.truncate() - comments = str(ph) if comments: patchf.write(comments)