{"thread":{"id":"28248","subject":"[PATCH 0/2] am: foreign patch support fixes","startedAt":"2011-08-29T16:44:05Z","lastAt":"2011-08-31T14:22:39Z","messageCount":9,"participants":["Giuseppe Bilotta","Junio C Hamano","Sverre Rabbelier"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"174462","messageId":"1314636247-26125-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"28248","inReplyTo":null,"subject":"[PATCH 0/2] am: foreign patch support fixes","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2011-08-29T16:44:05Z","receivedAt":"2011-08-29T16:44:05Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Two small patches to fix/enhance support for foreign patchset.\n\nThe first patch adds support for hg patches, which have been detected\n(but not supported) for a while. I've used it to import a couple of\npatches successfully.\n\nThe second patch fixes a rather long-standing issue with stgit patches,\nwhen Author was used instead of From. Apparently not many patches with\nthis format are encountered in the wild, since nobody had an issue with\nit so far.\n\nGiuseppe Bilotta (2):\n  am: preliminary support for hg patches\n  am: fix stgit patch mangling\n\n git-am.sh |   36 +++++++++++++++++++++++++++++++++++-\n 1 files changed, 35 insertions(+), 1 deletions(-)\n\n-- \n1.7.7.rc0.331.g25483.dirty\n"},{"id":"174463","messageId":"1314636247-26125-2-git-send-email-giuseppe.bilotta@gmail.com","threadId":"28248","inReplyTo":"1314636247-26125-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCH 1/2] am: preliminary support for hg patches","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2011-08-29T16:44:06Z","receivedAt":"2011-08-29T16:44:06Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n git-am.sh |   34 ++++++++++++++++++++++++++++++++++\n 1 files changed, 34 insertions(+), 0 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 4fff195..729ee51 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -311,6 +311,40 @@ split_patches ()\n \t\tthis=\n \t\tmsgnum=\n \t\t;;\n+\thg)\n+\t\tthis=0\n+\t\tfor hg in \"$@\"\n+\t\tdo\n+\t\t\tthis=`expr \"$this\" + 1`\n+\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n+\t\t\t# hg stores changeset metadata in #-commented lines preceding\n+\t\t\t# the commit message and diff(s). The only metadata we care about\n+\t\t\t# are the User and Date (Node ID and Parent are hashes which are\n+\t\t\t# only relevant to the hg repository and thus not useful to us)\n+\t\t\t# Since we cannot guarantee that the commit message is in git-friendly\n+\t\t\t# format, we put no Subject: line and just consume all of the message\n+\t\t\t# as the body\n+\t\t\tperl -M'POSIX qw(strftime)' -ne 'BEGIN { $subject = 0 }\n+\t\t\t\tif ($subject) { print ; }\n+\t\t\t\telsif (/^\\# User /) { s/\\# User/From:/ ; print ; }\n+\t\t\t\telsif (/^\\# Date /) {\n+\t\t\t\t\tmy ($hashsign, $str, $time, $tz) = split ;\n+\t\t\t\t\t$tz = sprintf \"%+05d\", (0-$tz)/36;\n+\t\t\t\t\tprint \"Date: \" .\n+\t\t\t\t\t      strftime(\"%a, %d %b %Y %H:%M:%S \",\n+\t\t\t\t\t\t       localtime($time))\n+\t\t\t\t\t      . \"$tz\\n\";\n+\t\t\t\t} elsif (/^\\# /) { next ; }\n+\t\t\t\telse {\n+\t\t\t\t\tprint \"\\n\", $_ ;\n+\t\t\t\t\t$subject = 1;\n+\t\t\t\t}\n+\t\t\t' < \"$hg\" > \"$dotest/$msgnum\" || clean_abort\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n \t*)\n \t\tif test -n \"$patch_format\" ; then\n \t\t\tclean_abort \"$(eval_gettext \"Patch format \\$patch_format is not supported.\")\"\n-- \n1.7.7.rc0.331.g25483.dirty\n"},{"id":"174464","messageId":"1314636247-26125-3-git-send-email-giuseppe.bilotta@gmail.com","threadId":"28248","inReplyTo":"1314636247-26125-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCH 2/2] am: fix stgit patch mangling","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2011-08-29T16:44:07Z","receivedAt":"2011-08-29T16:44:07Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n git-am.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 729ee51..14696d4 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -295,7 +295,7 @@ split_patches ()\n \t\t\tperl -ne 'BEGIN { $subject = 0 }\n \t\t\t\tif ($subject > 1) { print ; }\n \t\t\t\telsif (/^\\s+$/) { next ; }\n-\t\t\t\telsif (/^Author:/) { print s/Author/From/ ; }\n+\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n \t\t\t\telsif (/^(From|Date)/) { print ; }\n \t\t\t\telsif ($subject) {\n \t\t\t\t\t$subject = 2 ;\n-- \n1.7.7.rc0.331.g25483.dirty\n"},{"id":"174467","messageId":"7v62lg6tr3.fsf@alter.siamese.dyndns.org","threadId":"28248","inReplyTo":"1314636247-26125-2-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCH 1/2] am: preliminary support for hg patches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-29T16:57:04Z","receivedAt":"2011-08-29T16:57:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:\n\n> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n\nI'll leave nitpicking of this patch and helping to improve it to people\nwho actually have to deal with Hg generated patches for now.\n\n> +\thg)\n> +\t\tthis=0\n> +\t\tfor hg in \"$@\"\n> +\t\tdo\n> +\t\t\tthis=`expr \"$this\" + 1`\n> +\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n> +\t\t\t# hg stores changeset metadata in #-commented lines preceding\n> +\t\t\t# the commit message and diff(s). The only metadata we care about\n> +\t\t\t# are the User and Date (Node ID and Parent are hashes which are\n> +\t\t\t# only relevant to the hg repository and thus not useful to us)\n> +\t\t\t# Since we cannot guarantee that the commit message is in git-friendly\n> +\t\t\t# format, we put no Subject: line and just consume all of the message\n> +\t\t\t# as the body\n\nPersonally I am a bit worried about the phoney \"diff --git\" output Hg\nseems to (be able to) produce. Do they have \"index ...\" line that express\nthe blob object names in git terms (implausible), for example? We _might_\nwant to strip s/diff --git /diff / so that apply won't be confused if that\nturns out to be a problem.\n\nThanks.\n\n> +\t\t\tperl -M'POSIX qw(strftime)' -ne 'BEGIN { $subject = 0 }\n> +\t\t\t\tif ($subject) { print ; }\n> +\t\t\t\telsif (/^\\# User /) { s/\\# User/From:/ ; print ; }\n> +\t\t\t\telsif (/^\\# Date /) {\n> +\t\t\t\t\tmy ($hashsign, $str, $time, $tz) = split ;\n> +\t\t\t\t\t$tz = sprintf \"%+05d\", (0-$tz)/36;\n> +\t\t\t\t\tprint \"Date: \" .\n> +\t\t\t\t\t      strftime(\"%a, %d %b %Y %H:%M:%S \",\n> +\t\t\t\t\t\t       localtime($time))\n> +\t\t\t\t\t      . \"$tz\\n\";\n> +\t\t\t\t} elsif (/^\\# /) { next ; }\n> +\t\t\t\telse {\n> +\t\t\t\t\tprint \"\\n\", $_ ;\n> +\t\t\t\t\t$subject = 1;\n> +\t\t\t\t}\n> +\t\t\t' < \"$hg\" > \"$dotest/$msgnum\" || clean_abort\n> +\t\tdone\n> +\t\techo \"$this\" > \"$dotest/last\"\n> +\t\tthis=\n> +\t\tmsgnum=\n> +\t\t;;\n>  \t*)\n>  \t\tif test -n \"$patch_format\" ; then\n>  \t\t\tclean_abort \"$(eval_gettext \"Patch format \\$patch_format is not supported.\")\"\n"},{"id":"174473","messageId":"CAOxFTcyqGCB3TcS2CmFuVXqrCP2H-1aBDv3JJVKrNp-Q8Zahmg@mail.gmail.com","threadId":"28248","inReplyTo":"7v62lg6tr3.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] am: preliminary support for hg patches","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2011-08-29T17:51:35Z","receivedAt":"2011-08-29T17:51:35Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Mon, Aug 29, 2011 at 6:57 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:\n>\n>> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n>\n> I'll leave nitpicking of this patch and helping to improve it to people\n> who actually have to deal with Hg generated patches for now.\n\n[snip]\n\n>> +                     # hg stores changeset metadata in #-commented lines preceding\n>> +                     # the commit message and diff(s). The only metadata we care about\n>> +                     # are the User and Date (Node ID and Parent are hashes which are\n>> +                     # only relevant to the hg repository and thus not useful to us)\n>> +                     # Since we cannot guarantee that the commit message is in git-friendly\n>> +                     # format, we put no Subject: line and just consume all of the message\n>> +                     # as the body\n>\n> Personally I am a bit worried about the phoney \"diff --git\" output Hg\n> seems to (be able to) produce. Do they have \"index ...\" line that express\n> the blob object names in git terms (implausible), for example? We _might_\n> want to strip s/diff --git /diff / so that apply won't be confused if that\n> turns out to be a problem.\n\nNope, it doesn't have index .... lines. Still, the patches seems to\napply correctly. Well, the couple of patches I tested did, at least,\neven though they were marked as diff --git and they were lacking the\nindex ... lines.\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"},{"id":"174498","messageId":"7vd3fo53oe.fsf@alter.siamese.dyndns.org","threadId":"28248","inReplyTo":"CAOxFTcyqGCB3TcS2CmFuVXqrCP2H-1aBDv3JJVKrNp-Q8Zahmg@mail.gmail.com","subject":"Re: [PATCH 1/2] am: preliminary support for hg patches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-29T21:05:37Z","receivedAt":"2011-08-29T21:05:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:\n\n> Nope, it doesn't have index .... lines. Still, the patches seems to\n> apply correctly. Well, the couple of patches I tested did, at least,\n> even though they were marked as diff --git and they were lacking the\n> index ... lines.\n\nDoes \"am -3\" do the right thing when the patch does not apply cleanly, for\nexample? What about renaming patches?\n\nUntil we are reasonably sure that we can grok it reasonably well, I'd\nsleep better if we stripped \" --git\" part from a patch that is known to be\nproduced by somebody that does not fully re-implement \"git diff\".\n"},{"id":"174538","messageId":"CAOxFTczyNtyLWyXppj=0UW_zeD3t+rDtzt-vwqXkwvWOTdxi2g@mail.gmail.com","threadId":"28248","inReplyTo":"7vd3fo53oe.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] am: preliminary support for hg patches","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2011-08-30T08:28:33Z","receivedAt":"2011-08-30T08:28:33Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Mon, Aug 29, 2011 at 11:05 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:\n>\n>> Nope, it doesn't have index .... lines. Still, the patches seems to\n>> apply correctly. Well, the couple of patches I tested did, at least,\n>> even though they were marked as diff --git and they were lacking the\n>> index ... lines.\n>\n> Does \"am -3\" do the right thing when the patch does not apply cleanly, for\n> example?\n\nthree-way merges are impossible because all hash information is being\nstripped (hg stores them in the Node ID and Parent metadata, which we\nstrip, and has no index metadata for the actual diff blocks). This is\ncorrectly detected by -3, with\n\nApplying: Threeway test\nfatal: sha1 information is lacking or useless (dir.h).\nRepository lacks necessary blobs to fall back on 3-way merge.\nCannot fall back to three-way merge.\nPatch failed at 0001 Threeway test\n\nThe message is a bit misleading (it's not the repo lacking the blobs,\nit's the patch missing the information), but the process fails as\nexpected.\n\n> What about renaming patches?\n\nThey lack similarity indices, but they seem to be properly formated\n(and the simple cases I tested apply correctly).\n\nIn fact, stripping the --git from an hg patch containing a rename\nmakes the patch unusable:\n\nerror: datetime.move: does not exist in index\nPatch failed at 0001 Move\n\nSo I think that keeping the --git is the right choice.\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"},{"id":"174559","messageId":"7vwrdu3ka0.fsf@alter.siamese.dyndns.org","threadId":"28248","inReplyTo":"CAOxFTczyNtyLWyXppj=0UW_zeD3t+rDtzt-vwqXkwvWOTdxi2g@mail.gmail.com","subject":"Re: [PATCH 1/2] am: preliminary support for hg patches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-30T17:02:15Z","receivedAt":"2011-08-30T17:02:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:\n\n> ... This is\n> correctly detected by -3, with\n>\n> Applying: Threeway test\n> fatal: sha1 information is lacking or useless (dir.h).\n> Repository lacks necessary blobs to fall back on 3-way merge.\n> Cannot fall back to three-way merge.\n> Patch failed at 0001 Threeway test\n>\n> The message is a bit misleading (it's not the repo lacking the blobs,\n> it's the patch missing the information), but the process fails as\n> expected.\n>\n>> What about renaming patches?\n>\n> They lack similarity indices, but they seem to be properly formated\n> (and the simple cases I tested apply correctly).\n\nThese were exactly what I wanted to know. Thanks for experimenting.\n\n> So I think that keeping the --git is the right choice.\n\nYeah, sounds like we are safe and better off keeping it.\n"},{"id":"174611","messageId":"CAGdFq_gerRi6REiU4HRqD4SgxBA3obMofAzw7HE4Qkxy82k7Sw@mail.gmail.com","threadId":"28248","inReplyTo":"7vwrdu3ka0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] am: preliminary support for hg patches","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2011-08-31T14:22:39Z","receivedAt":"2011-08-31T14:22:39Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Tue, Aug 30, 2011 at 19:02, Junio C Hamano <gitster@pobox.com> wrote:\n> These were exactly what I wanted to know. Thanks for experimenting.\n\nAnd thanks for working on this, Giuseppe!\n\n-- \nCheers,\n\nSverre Rabbelier\n"}]}