diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -909,7 +909,16 @@ class queue: patchparent = self.qparents(repo, top) message, comments, user, date, patchfound = self.readheaders(patchfn) - patchf = self.opener(patchfn, "w") + 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 + patchf.seek(0) + patchf.truncate() + msg = opts.get('msg', '').rstrip() if msg: if comments: