diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2011-08-29 18:44:06 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-08-29 10:21:17 -0700 |
commit | 0cfd112032017ab68ed576f6bb5258452084ebf1 (patch) | |
tree | 8fd4b065ce828827dd16a4efb1c30faa8d96ef46 | |
parent | c574e683b587ee3c302317e4fa9c83cd4605cd82 (diff) | |
download | git-0cfd112032017ab68ed576f6bb5258452084ebf1.tar.gz |
am: preliminary support for hg patches
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-x | git-am.sh | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -248,6 +248,40 @@ split_patches () { this= msgnum= ;; + hg) + this=0 + for hg in "$@" + do + this=$(( $this + 1 )) + msgnum=$(printf "%0${prec}d" $this) + # hg stores changeset metadata in #-commented lines preceding + # the commit message and diff(s). The only metadata we care about + # are the User and Date (Node ID and Parent are hashes which are + # only relevant to the hg repository and thus not useful to us) + # Since we cannot guarantee that the commit message is in + # git-friendly format, we put no Subject: line and just consume + # all of the message as the body + perl -M'POSIX qw(strftime)' -ne 'BEGIN { $subject = 0 } + if ($subject) { print ; } + elsif (/^\# User /) { s/\# User/From:/ ; print ; } + elsif (/^\# Date /) { + my ($hashsign, $str, $time, $tz) = split ; + $tz = sprintf "%+05d", (0-$tz)/36; + print "Date: " . + strftime("%a, %d %b %Y %H:%M:%S ", + localtime($time)) + . "$tz\n"; + } elsif (/^\# /) { next ; } + else { + print "\n", $_ ; + $subject = 1; + } + ' <"$hg" >"$dotest/$msgnum" || clean_abort + done + echo "$this" >"$dotest/last" + this= + msgnum= + ;; *) echo "Patch format $patch_format is not supported." exit 1 |