From: Junio C Hamano <gitster@pobox.com>
To: Jan Nieuwenhuizen <janneke-list@xs4all.nl>
Cc: Petr Baudis <pasky@suse.cz>, git@vger.kernel.org
Subject: Re: [PATCH] git-svn.perl: Strip ChangeLog bits.
Date: Sat, 02 Aug 2008 14:13:03 -0700 [thread overview]
Message-ID: <7v4p63dstc.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 1217701021.8296.35.camel@heerbeest
Jan Nieuwenhuizen <janneke-list@xs4all.nl> writes:
> On za, 2008-08-02 at 10:36 -0700, Junio C Hamano wrote:
>
>> > You forgot to document your option. (And possibly write a testcase.)
>>
>> I am not sure if this is generic enough to be in git-svn.perl itself, or
>> perhaps there should be a hook make_log_entry() would call in the form of
>> some Perl scriptlet given by the user to munge $log_entry{log}, which
>> would be very specific to each project.
>
> If you're not sure, please make up your mind.
That's something you would say when I cannot decide the color of
bikeshed. I do not think your change falls into that category.
We could add an ad-hoc preprocessing option like this, and keep adding
more for different patterns, and at certain point we may be fed up with
millions of such options and try to introduce a more generic mechanism.
While doing so, the resulting code needs to support the ad-hoc ones that
are added earlier, forever.
We've done that in the past with other commands (cc-suppression scheme in
send-email comes to mind). It was very unpleasant.
> ... Doing this in a single
> regexp is a bit tricky and asking a user to write a perl snippet is even
> worse, imho.
What you are saying is that a built-in one, no matter what, won't be
sufficient for many projects. Unless a user writes Perl snippet to match
his project's needs, the noise at the beginning of the log won't be
stripped for him.
That's fine. I do not expect a single built-in transformation would fit
everybody's needs. I am not asking for miracles.
But you could at least keep the door open for people who are _willing_ to
write such transformation for their projects, right?
For one thing, your --cut-changelog-bits has one fixed pattern. Later
people either have to come up with different option, or modify your
pattern (potentially breaking your project). Neither is good.
Perhaps doing something like this a (admittedly slightly) better option?
It allows you to choose from a canned set, or give a series of s///
rewriting rules (or whatever you would want to have in the custom function)..
---
git-svn.perl | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index cf6dbbc..eaf6a56 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit,
$_version, $_fetch_all, $_no_rebase,
$_merge, $_strategy, $_dry_run, $_local,
$_prefix, $_no_checkout, $_url, $_verbose,
- $_git_format);
+ $_git_format, $_clean_changelog, $_clean_log_message);
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -109,9 +109,11 @@ my %cmd = (
fetch => [ \&cmd_fetch, "Download new revisions from SVN",
{ 'revision|r=s' => \$_revision,
'fetch-all|all' => \$_fetch_all,
+ 'clean-changelog=s' => \$_clean_changelog,
%fc_opts } ],
clone => [ \&cmd_clone, "Initialize and fetch revisions",
{ 'revision|r=s' => \$_revision,
+ 'clean-changelog=s' => \$_clean_changelog,
%fc_opts, %init_opts } ],
init => [ \&cmd_init, "Initialize a repo for tracking" .
" (requires URL argument)",
@@ -238,6 +240,33 @@ my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,
$Git::SVN::default_repo_id = $_[1] });
exit 1 if (!$rv && $cmd && $cmd ne 'log');
+my %canned_changelog_cleaner =
+(
+ 'ooo' => sub {
+ local ($_) = @_;
+ s/(^|\n)\s*((\n|\s)*(199[0-9]|20[0-1][0-9])(-[0-9]{2}){2}\s+.*<.*>\s*\n\s+)?/$1/g;
+ s/(^|\n)\* /\n$1/g;
+ s/^[\n\s]*//;
+ s/\n\s*/ /g if length ($_) < 81;
+ "\n";
+ }
+);
+
+if (defined $_clean_changelog) {
+ if (exists $canned_changelog_cleaner{$_clean_changelog}) {
+ $_clean_log_message = $canned_changelog_cleaner{$_clean_changelog};
+ } elsif ($_clean_changelog ne '') {
+ $_clean_log_message = eval "
+ sub { local(\$_) = \@_; $_clean_changelog; return \$_; }
+ ";
+ if ($@) {
+ die "$!: $_clean_changelog";
+ }
+ } else {
+ die "$_clean_changelog: unknown way to clean log message";
+ }
+}
+
usage(0) if $_help;
version() if $_version;
usage(1) unless defined $cmd;
@@ -2463,6 +2492,9 @@ sub make_log_entry {
close $un or croak $!;
$log_entry{date} = parse_svn_date($log_entry{date});
+ if ($_clean_log_message) {
+ $log_entry{log} = $_clean_log_message->($log_entry{log});
+ }
$log_entry{log} .= "\n";
my $author = $log_entry{author} = check_author($log_entry{author});
my ($name, $email) = defined $::users{$author} ? @{$::users{$author}}
next prev parent reply other threads:[~2008-08-02 21:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-02 13:42 [PATCH] git-svn.perl: Strip ChangeLog bits Jan Nieuwenhuizen
2008-08-02 17:27 ` Petr Baudis
2008-08-02 17:36 ` Junio C Hamano
2008-08-02 18:17 ` Jan Nieuwenhuizen
2008-08-02 21:13 ` Junio C Hamano [this message]
2008-08-03 12:07 ` Jan Nieuwenhuizen
2008-08-03 20:45 ` Junio C Hamano
2008-08-04 8:07 ` Jan Nieuwenhuizen
2008-08-04 2:09 ` Eric Wong
2008-08-04 2:45 ` Junio C Hamano
2008-08-04 7:49 ` Jan Nieuwenhuizen
2008-08-04 9:03 ` Eric Wong
2008-08-04 11:30 ` Jan Nieuwenhuizen
2008-08-02 18:21 ` Jan Nieuwenhuizen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v4p63dstc.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=janneke-list@xs4all.nl \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).