Hi Jonathan, On Mon, Apr 26, 2010 at 08:27:10AM -0500, Jonathan Nieder wrote: > Jens Seidel wrote: > > since it is possible that the commit log of a Subversion repository is > > changed I want to compare my git log with the svn log: > > As a silly workaround, I’d suggest coming up with a substitution to make > them look the same. For example, you could remove all strings in > parentheses.
yep, one has to apply a filter, also to remove the addional empty lines (and non matching spaces at end of lines). > > git: > > r2105 | viktor | 2010-03-19 13:40:54 +0100 (Fr, 19 Mär 2010) | 2 lines > > > > svn: > > r2105 | viktor | 2010-03-19 13:40:54 +0100 (Fr, 19. Mär 2010) | 1 Zeile > > > > First of all the dot after the day of month is missing in the German locale. 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. > Care to write a patch? This sounds like a useful change, but realistically > speaking, I do not see anyone working on it soon. I’d be glad to help in > any way I can (pointing to relevant functions and so on). Here is a patch with a few comments, also attached unchanged: Please note that I don't know Perl. Please check my changes very carefully! --- /usr/lib/git-core/git-svn.orig 2010-04-11 19:14:03.000000000 +0200 +++ /usr/lib/git-core/git-svn 2010-04-27 12:50:51.000000000 +0200 @@ -50,6 +50,7 @@ use Carp qw/croak/; use Digest::MD5; use IO::File qw//; +use Locale::gettext; Let's use the gettext system which is also used by Subversion and is the quasi standard for translations. I hope this doesn't increase the dependencies of git-svn. @@ -5492,7 +5495,8 @@ my $gm = timelocal(gmtime($t)); my $sign = qw( + + - )[ $t <=> $gm ]; my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]); - return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t)); + my $d = Locale::gettext->domain("subversion"); I'm not sure whether it is efficient to perform this call here. Maybe it should be a (global???) variable. Let's reuse existing Subversion translations (why not -?)). + return strftime("%Y-%m-%d %H:%M:%S $gmoff" . $d->get(" (%a, %d %b %Y)"), localtime($t)); Only the last part can be changed by translators in Subversion. See trunk, file libsvn_subr/time.c: /* Machine parseable part, generated by apr_snprintf. */ #define HUMAN_TIMESTAMP_FORMAT "%.4d-%.2d-%.2d %.2d:%.2d:%.2d %+.2d%.2d" /* Human explanatory part, generated by apr_strftime as "Sat, 01 Jan 2000" * */ #define human_timestamp_format_suffix _(" (%a, %d %b %Y)") @@ -5598,20 +5603,15 @@ } $nr_line = scalar @$l; if (!$nr_line) { - print "1 line\n\n\n"; + print sprintf($d->nget(" | %d line", " | %d lines", 1), 1), "\n\n\n"; Please put sprintf($d->nget(" | %d line", " | %d lines", n), n) into a function (which integer parameter n) to avoid code duplication. The first n selects the string to be used (the singular or plural form), the second replaces %d by the number. Since Subversion has the string " | %d line" translated, we have to match it (and cannot request the translation for "line"). I tried it and it works well. Jens
--- /usr/lib/git-core/git-svn.orig 2010-04-11 19:14:03.000000000 +0200 +++ /usr/lib/git-core/git-svn 2010-04-27 12:50:51.000000000 +0200 @@ -50,6 +50,7 @@ use Carp qw/croak/; use Digest::MD5; use IO::File qw//; +use Locale::gettext; use File::Basename qw/dirname basename/; use File::Path qw/mkpath/; use File::Spec; @@ -5492,7 +5495,8 @@ my $gm = timelocal(gmtime($t)); my $sign = qw( + + - )[ $t <=> $gm ]; my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]); - return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t)); + my $d = Locale::gettext->domain("subversion"); + return strftime("%Y-%m-%d %H:%M:%S $gmoff" . $d->get(" (%a, %d %b %Y)"), localtime($t)); } sub parse_git_date { @@ -5588,9 +5592,10 @@ my ($c) = @_; print commit_log_separator, "r$c->{r} | "; print "$c->{c} | " if $show_commit; - print "$c->{a} | ", format_svn_date($c->{t_utc}), ' | '; + print "$c->{a} | ", format_svn_date($c->{t_utc}); my $nr_line = 0; + my $d = Locale::gettext->domain("subversion"); if (my $l = $c->{l}) { while ($l->[$#$l] eq "\n" && $#$l > 0 && $l->[($#$l - 1)] eq "\n") { @@ -5598,20 +5603,15 @@ } $nr_line = scalar @$l; if (!$nr_line) { - print "1 line\n\n\n"; + print sprintf($d->nget(" | %d line", " | %d lines", 1), 1), "\n\n\n"; } else { - if ($nr_line == 1) { - $nr_line = '1 line'; - } else { - $nr_line .= ' lines'; - } - print $nr_line, "\n"; + print sprintf($d->nget(" | %d line", " | %d lines", $nr_line), $nr_line), "\n"; show_commit_changed_paths($c); print "\n"; print $_ foreach @$l; } } else { - print "1 line\n"; + print sprintf($d->nget(" | %d line", " | %d lines", 1), 1), "\n"; show_commit_changed_paths($c); print "\n";