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

CONTRIB: svnlogfilter, alternative to search-svnlog.pl

From: David Marshall <dmarshall_at_gmail.com>
Date: 2005-05-03 04:38:24 CEST

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.

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
Received on Tue May 3 04:39:15 2005

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.