“hg import” is unable to correctly import patches generated by “git-format- patch”. STEPS TO REPRODUCE: 1. Create a patch from a git repository using e.g. “git format-patch -3” to generate patches for the last three changesets. If you don’t want to touch git, use the attached file. :) 2. Import the patch using “hg import <filename>” Note: I don’t know much about git, so it’s possible that with different invocations of git-format-patch, the format will be different. EXPECTED RESULTS: The commit message should be taken from the subject. If the commit message is multi-line, read lines up to (but not including) a line containing only “---”. For example, the attached patch should result in a commit message “updated sass test to make it work with sass 3”. ACTUAL RESULTS: The commit message is the following: updated sass test to make it work with sass 3 --- test/filters/test_sass.rb | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) The last three lines should not be present in the commit message.
One more thing: the subject, which contains the changeset message, includes a prefix (usually [PATCH] or [PATCH x/y] according to the man page) that should be stripped from the subject. Given the large amount of options for git-format-patch, it looks like checking the source code for the git-am tool may be useful in order to figure out how these e-mails are parsed.
[PATCH] or [PATCH x/y] is already stripped correctly. Or do you have an actual example of hg import failing to interpret those tags? For the stats/scissors issue, I am working on a patch to add options to import to support those. Cheers,
I haven’t actually checked whether the [PATCH] or [PATCH x/y] is stripped; I merely wanted to mention it, just in case.
There seems to be some activity related to this on github, if anyone's interested: https://github.com/froydnj/patch-converter
Pretty sure this has worked for a while now already. Tests here confirm that bits after "--- " are properly stripped and description is subject + body.
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:08 EDT --- This bug was previously known as _bug_ 2148 at http://mercurial.selenic.com/bts/issue2148 Imported an attachment (id=1375)
Created attachment 1668 [details] Sample patchfile The issue is back in Mercurial version 2.2.1 (maybe earlier). Symptoms: 1) The following is not ignored: --- ... stats ... diff ... 2) The Date: field is not respected. Sample patchfile attached.
Further issues: Git formats Subject: lines with linebreaks, but hg does not reconcat them again.
(In reply to comment #8) > Further issues: Git formats Subject: lines with linebreaks, but hg does not reconcat them again. Sorry, that is actually a bug in https://github.com/MarkLodato/patch-converter which I used as a workaround.
a) We expect the diffstat separator is "---[ \t]", git is apparently now generating only "---" b) We've apparently never supported Date: headers.
Unassign some bugs with no activity.
Fixed by http://selenic.com/repo/hg/rev/9e8298a324ac Matt Mackall <mpm@selenic.com> import: cut commit messages at --- unconditionally (issue2148) We used to do this based on X-mailer: mentioning git, but git doesn't put X-mailer in its git-format-patch output. (please test the fix)