Skip to content

Commit

Permalink
am: preliminary support for hg patches
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Bilotta <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Oblomov authored and gitster committed Aug 29, 2011
1 parent c574e68 commit 0cfd112
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0cfd112

Please sign in to comment.