Re: [PATCH/WIP] git-svn: tweak log format to match "svn log" output
- From
- Eric Wong <normalperson@yhbt.net>
- Date
- Jul 25, 2010, 08:10 UTC
- Message-ID
- <20100725081057.GA22373@dcvr.yhbt.net>
- In-Reply-To
- <20100725023114.GB18606@burratino>
Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 5 quoted lines
> From: Jens Seidel <jensseidel@users.sf.net> > > Tweak "git svn log" output to more closely match what svn produces. > In particular, if Locale::gettext is available, use that to produce > localized output using svn’s translations.
<snip>
Show 19 quoted lines
> [jn: made Locale::gettext dependency optional; added a test script] > > Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> > --- > Jens Seidel wrote at http://bugs.debian.org/578915: > >> Jens Seidel wrote: > > > Ah, git svn ignores any locale, this explains the problem. > > > >>> The dot stands for an ordinal number (e.g. "19." == "19th"). > >>> Second: "line(s)" is not translated. I can workaround by starting git/svn in an > >>> English locale ... > > > > I tried to fix both. > > > >>> Third: the git log often contains an addional empty line. > > > This remains open. Probably that can be solved by setting a git config > > option and resyncing all git svn history from git.
Hi Jens, Jonathan,
I just made an additional patch that should solve the problem (see my reply to this email).
Show 10 quoted lines
> Sorry to leave this hanging for so long. I think it is an improvement > as is, but I have not tested in the following scenarios: > > - Locale::gettext not available > - subversion not translated > - subversion translated but not to the current language > > And the extra blank line at the end of log messages remains unsolved. > > Thoughts?
Everything looks reasonable to me. gettext should just fall back to the original string when a translation is not available.
I've squashed the following cleanup on top of Jens' original change:
diff --git a/git-svn.perl b/git-svn.perl index 55dc50d..5252722 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5536,14 +5536,12 @@ sub format_svn_date { my $gm = timelocal(gmtime($t)); my $sign = qw( + + - )[ $t <=> $gm ]; my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]); - my $format; + my $format = " (%a, %d %b %Y)"; if ($can_localize) { my $d = Locale::gettext->domain("subversion"); - $format = "%Y-%m-%d %H:%M:%S $gmoff" . $d->get(" (%a, %d %b %Y)"); - } else { - $format = "%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)"; + $format = $d->get($format); } - return strftime($format, localtime($t)); + return strftime("%Y-%m-%d %H:%M:%S $gmoff$format", localtime($t)); } sub parse_git_date { @@ -5646,8 +5644,8 @@ sub show_commit_normal { if ($can_localize) { my $d = Locale::gettext->domain("subversion"); - $sing_fmt = $d->nget(" | %d line", " | %d lines", 1); - $plur_fmt = $d->nget(" | %d line", " | %d lines", 10); + $sing_fmt = $d->nget($sing_fmt, $plur_fmt, 1); + $plur_fmt = $d->nget($sing_fmt, $plur_fmt, 10); } if (my $l = $c->{l}) { while ($l->[$#$l] eq "\n" && $#$l > 0
-- Eric Wong