This is very similar to issue 2790. The format of the metadata at the beginning of the patch differs between patches generated via MQ (qrefresh) and via hg export. In the MQ case, it looks like this: # Node ID 5f96d29476f51fbd2e2e29c8694ef7fe9fb1b226 # Parent 7b5f756b82327291e62dc7e3360cadd07b7a6207 while hg export produces this: # Node ID b55f48d8b9d941e8d1e4a70777e032e011104404 # Parent 7b5f756b82327291e62dc7e3360cadd07b7a6207 Consequently, hg import --exact fails to apply the MQ-generated patch. It complains thusly: abort: unknown revision 'b5f756b82327291e62dc7e3360cadd07b7a6207'! Note the stripped first character of the parent hash. It would be good to make both formats equal for an improved patch handling experience. Also, hg import --exact should be made more tolerant regarding the formatting of the patch, like it has been done for qpush --exact before. $ hg version Mercurial Distributed SCM (version 2.0.2+145-878bc4a62a73)
That the node id is different was an error on my part. The formatting of the "Parent" line is the important part.
I know this is not for patches, but maybe a patch fragment is tolerated. This makes the import more tolerant. --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -230,7 +230,7 @@ elif line.startswith("# Node ID "): nodeid = line[10:] elif line.startswith("# Parent "): - parents.append(line[10:]) + parents.append(line[9:].strip()) elif not line.startswith("# "): hgpatchheader = False elif line == '---' and gitsendmail:
Thank you for the report, I have submitted a slightly different patch here: http://selenic.com/pipermail/mercurial-devel/2012-April/039378.html Upgrading to bug.
Fixed by http://selenic.com/repo/hg/rev/1f75c1decdeb Patrick Mezard <patrick@mezard.eu> patch: be more tolerant with "Parent" header (issue3356) (please test the fix)
Thanks for the fix. I tested it, and this specific problem is gone. However, I still cannot import MQ-generated patches because they miss a node ID. I don't know where the IDs in my original examples came from, but when I use qnew or qrefresh now, no node ID gets written. hg import --exact complains about this: abort: not a Mercurial patch
Could you open another issue about this?
Done.
Marking this one resolved.
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:29 EDT --- This bug was previously known as _bug_ 3356 at http://mercurial.selenic.com/bts/issue3356