[PATCH] export: show 'Date' header in a format that also is readable for humans
Matt Mackall
mpm at selenic.com
Sun Feb 10 09:45:52 CST 2013
On Sun, 2013-02-10 at 13:12 +0100, Mads Kiilerich wrote:
> On 02/10/2013 12:53 PM, Brodie Rao wrote:
> > On Sat, Feb 9, 2013 at 9:31 AM, Mads Kiilerich <mads at kiilerich.com> wrote:
> >> # HG changeset patch
> >> # User Mads Kiilerich <mads at kiilerich.com>
> >> # Date 1360360457 -3600
> >> # Node ID 055060daf58dbe46c667053cbb04409b202ee9cd
> >> # Parent 97761496c65ae836d6b0983a3f48959dd3112364
> >> export: show 'Date' header in a format that also is readable for humans
> >>
> >> 'export' is the official export format and used by patchbomb, but it would only
> >> show date as a timestamp that most humans might find it hard to relate to. It
> >> would be very convenient when reviewing a patch to be able to see what
> >> timestamp the patch will end up with.
> >>
> >> Mercurial has always used util.parsedate for parsing these headers. It can
> >> handle 'all' date formats, so we could just as well use a readable one.
> > Are there any third party utilities that parse these headers? I wonder
> > if this might cause other tools to break.
>
> Yes, that is a valid concern, but we don't expect that. Parsers should
> read it as Mercurial do, and Mercurial has always been able to handle
> all formats.
>
> So I will put it in 'default' and we can wait and see if it really
> becomes a problem.
After a bit of poking, I've discovered this in Git:
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
LANG=C LC_ALL=C 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
so we're going to try something different.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list