git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] am: preliminary support for hg patches

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 29, 2011, 16:57 UTC
Message-ID
<7v62lg6tr3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1314636247-26125-2-git-send-email-giuseppe.bilotta@gmail.com>
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>

I'll leave nitpicking of this patch and helping to improve it to people who actually have to deal with Hg generated patches for now.

Show 13 quoted lines
> +	hg)
> +		this=0
> +		for hg in "$@"
> +		do
> +			this=`expr "$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

Personally I am a bit worried about the phoney "diff --git" output Hg seems to (be able to) produce. Do they have "index ..." line that express the blob object names in git terms (implausible), for example? We _might_ want to strip s/diff --git /diff / so that apply won't be confused if that turns out to be a problem.

Thanks.
Show 24 quoted lines
> +			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=
> +		;;
>  	*)
>  		if test -n "$patch_format" ; then
>  			clean_abort "$(eval_gettext "Patch format \$patch_format is not supported.")"
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 3 of 9 in “am: foreign patch support fixes”
  1. 0/2 am: foreign patch support fixesGiuseppe Bilotta, Aug 29, 2011
  2. 1/2 am: preliminary support for hg patchesGiuseppe Bilotta, Aug 29, 2011
  3. Junio C HamanoAug 29, 2011
  4. Giuseppe BilottaAug 29, 2011
  5. Junio C HamanoAug 29, 2011
  6. Giuseppe BilottaAug 30, 2011
  7. Junio C HamanoAug 30, 2011
  8. Sverre RabbelierAug 31, 2011
  9. 2/2 am: fix stgit patch manglingGiuseppe Bilotta, Aug 29, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.