[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: CONTRIB: svnlogfilter, alternative to search-svnlog.pl

From: <kfogel_at_collab.net>
Date: 2005-05-03 05:32:59 CEST

David Marshall <dmarshall@gmail.com> writes:
> search-svnlog.pl is fine, but I needed just a little bit more. I
> grant permission for changing the copyright notice from me to whatever
> is customary, CollabNet or whatever.
>
> Thank you for Subversion! I'm glad to be able to contribute, albeit
> in an extremely marginal way.

Thanks! This looks better than search-svnlog.pl.

I noticed that you're just looking for the standard line of hyphens,
and not using the "| NNN lines" portion of the log message header. In
practice this is probably fine (who would put a line of 72 hyphens in
their log message?) but to be absolutely secure you might want to
check the line count.

In Subversion 2.0, I'm +1 on getting rid of the line count and just
disallowing a line of 72 hyphens in the log message, by the way :-).

Instead of having separate flags to indicate negation, why not just
long forms '--not-regexp' and '--not-user'? It seems counterintuitive
that the main functionality is available only via longopts, yet the
"special cases" are achieved via shortopts.

If this completely subsumes the functionality of search-svnlog.pl,
which it looks like it does, I'd be happy to have it just replace
search-svnlog.pl in the long run. Would you be okay with that name,
or do you prefer "svnlogfilter"?

-Karl

> Index: contrib/client-side/svnlogfilter
> ===================================================================
> --- contrib/client-side/svnlogfilter (revision 0)
> +++ contrib/client-side/svnlogfilter (revision 0)
> @@ -0,0 +1,133 @@
> +#!/usr/bin/perl
> +use warnings;
> +use strict;
> +
> +# ====================================================================
> +# Show log messages matching certain patterns. Usage:
> +#
> +# svnlogfilter [--user USER] [-n] [--regex REGEX] [-v]
> +#
> +# See pod for details.
> +#
> +# ====================================================================
> +# Copyright (c) 2005 David Marshall <marshall@chezmarshall.com>.
> +# All rights reserved.
> +#
> +# This software is licensed as described in the file COPYING, which
> +# you should have received as part of this distribution. The terms
> +# are also available at http://subversion.tigris.org/license-1.html.
> +# If newer versions of this license are posted there, you may use a
> +# newer version instead, at your option.
> +#
> +# This software consists of voluntary contributions made by many
> +# individuals. For exact contribution history, see the revision
> +# history and logs, available at http://subversion.tigris.org/.
> +# ====================================================================
> +
> +use Getopt::Long;
> +use Pod::Usage;
> +
> +my ($user, $not_user, $regex, $inverted, $help, $man);
> +
> +GetOptions(
> + 'user=s' => \$user,
> + 'n' => \$not_user,
> + 'regex=s' => \$regex,
> + 'v' => \$inverted,
> + 'help|?' => \$help,
> + 'man' => \$man,
> +) or pod2usage(2);
> +
> +pod2usage(1) if $help;
> +pod2usage(-exitstatus => 0, -verbose => 2) if $man;
> +
> +pod2usage("$0: either user or regex required\n") unless $user || $regex;
> +
> +if ($regex) {
> + eval {
> + $regex = qr/$regex/;
> + };
> +
> + pod2usage("$0: regex error: $@\n") if $@;
> +}
> +
> +pod2usage("$0: bogus user name: $user\n") if $user =~ /\W/;
> +
> +local $/ = '-' x 72 . "\n";
> +local $\ = $/;
> +local $, = $/;
> +
> +chomp (my @log = <>);
> +
> +if ($user) {
> + my $user_regex = qr/^r\d+\s+\|\s+$user/;
> + if ($not_user) {
> + @log = grep !/$user_regex/, @log;
> + } else {
> + @log = grep m/$user_regex/, @log;
> + }
> +}
> +
> +if ($regex) {
> + if ($inverted) {
> + @log = grep !/$regex/, @log;
> + } else {
> + @log = grep m/$regex/, @log;
> + }
> +}
> +
> +print ('', @log);
> +__END__
> +
> +=head1 NAME
> +
> +svnlogfilter - filter Subversion log output
> +
> +=head1 SYNOPSIS
> +
> +svnlogfilter [options] [file...]
> +svn log ... | svnlogfilter [options]
> +
> + Options:
> + --user include only changes made by the named user
> + --regex include only changes that include this regex
> + -n invert sense of --user
> + -v invert sense of --regex
> + --help brief help message
> + --man full documentation
> +
> +=head1 OPTIONS
> +
> +=over 8
> +
> +=item B<--user>
> +
> +Includes only log entries describing changes by this user.
> +
> +=item B<--regex>
> +
> +Includes only log entries that match this regex.
> +
> +=item B<-n>
> +
> +Inverts the sense of --user; only includes entries NOT made by --user
> +
> +=item B<-v>
> +
> +Inverts the sense of --regex; only includes entries NOT matching --regex
> +
> +=item B<--help>
> +
> +Prints a brief help message and exits.
> +
> +=item B<--man>
> +
> +Prints the manual page and exits.
> +
> +=back
> +
> +=head1 DESCRIPTION
> +
> +This script filters a list of Subversion log messages to find those
> committed by a particular user, those that match a particular regular
> expression, or both. The sense of the matches can be inverted.
> +
> +=cut
>
> Property changes on: contrib/client-side/svnlogfilter
> ___________________________________________________________________
> Name: svn:executable
> + *
> Name: svn:eol-style
> + native
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 3 06:05:42 2005

This is an archived mail posted to the Subversion Dev mailing list.