[svk-devel] [PATCH] filtering for any but a list of authors

Lanny Ripple lanny at cisco.com
Sat Mar 31 00:47:17 EDT 2007


I tend to commit more often than others in my team at work and
didn't see an easy way to filter for any author not me.  I wrote
something to do it and thought I'd offer it back in case it has
some utility.

    Cheers,
    -ljr
-- 
Lanny Ripple <lanny at cisco.com>
ScmDB / Cisco Systems, Inc.

-------------- next part --------------
==== Patch <svk_author_not> level 1
Source: [No source]
Target: 4ccb8a5b-8ae0-0310-9b02-86531366991d:/trunk:2371
        (http://code.bestpractical.com/svk/trunk)
Log:
* Author.pm
  + add filtering for any but listed authors

* 25log-filter.t
  + tests on 'author !'
=== lib/SVK/Log/Filter/Author.pm
==================================================================
--- lib/SVK/Log/Filter/Author.pm	(revision 2371)
+++ lib/SVK/Log/Filter/Author.pm	(patch svk_author_not level 1)
@@ -60,9 +60,13 @@
 sub setup {
     my ($self) = @_;
 
-    my $search = $self->{argument}
-        or die loc("Author: at least one author name is required.\n");
+    my $search = $self->{argument};
 
+    die loc("Author: at least one author name is required.\n")
+	unless ( defined $search && $search !~ /^\s* ! \s*$/xms );
+
+    $self->{wants_not} = $search =~ s/^\s* ! \s*//xms;
+
     my @matching_authors = split /\s* , \s*/xms, $search;
     $self->{names} = \@matching_authors;
     $self->{wants_none} = grep { $_ eq '(none)' } @matching_authors;
@@ -80,7 +84,8 @@
     }
 
     # look for a matching, existent author
-    return if any { $_ eq $author } @{ $self->{names} };
+    return
+        if ( $self->{wants_not} ^ any { $_ eq $author } @{ $self->{names} } );
 
     # no match, so skip to the next revision
     $self->pipeline('next');
@@ -100,11 +105,16 @@
 svn:author property is equal to any of the names, the revision is allowed to
 continue down the pipeline.  Otherwise, the revision is skipped.  The special
 author name "(none)" means to look for revisions with no svn:author property.
+If a "!" prepends all names then the sense of the search is reversed.
 
 For example, to search for all commits by either "jack" or "jill" one might do
 
     svk log --filter "author jill,jack"
 
+To search for all commits made by anyone but "jack" or "jill" one might try
+
+    svk log --filter "author !jack,jill"
+
 To locate those revisions without an author, this command may be used
 
     svk log --filter "author (none)"
=== t/25log-filter.t
==================================================================
--- t/25log-filter.t	(revision 2371)
+++ t/25log-filter.t	(patch svk_author_not level 1)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 use strict;
 use SVK::Test;
-plan tests => 24;
+plan tests => 28;
 
 # working copy initialization
 our $output;
@@ -212,6 +212,37 @@
         qr/-+/,
     ],
 );
+is_output(
+    $svk, 'log', [ '-q', '--filter', 'author ! person,another' ],
+    [
+        qr/-+/,
+        qr/r3:/,
+        qr/-+/,
+    ],
+);
+is_output(
+    $svk, 'log', [ '-q', '--filter', 'author !(none)' ],
+    [
+        qr/-+/,
+        qr/r4:/,
+        qr/-+/,
+        qr/r2:/,
+        qr/-+/,
+        qr/r1:/,
+        qr/-+/,
+    ],
+);
+is_output(
+    $svk, 'log',
+    [ '-q', '--filter', 'author \!person, another, (none)' ], # user '!person'
+    [
+        qr/-+/,
+        qr/r3:/,
+        qr/-+/,
+        qr/r2:/,
+        qr/-+/,
+    ],
+);
 
 
 # test some error conditions
@@ -240,6 +271,12 @@
     ],
 );
 is_output(
+    $svk, 'log', [ '--filter', 'author !' ],
+    [
+        q(Author: at least one author name is required.),
+    ],
+);
+is_output(
     $svk, 'log', [ '--filter', 'std' ],
     [
         q(Cannot use the output filter "std" in a selection pipeline.),

==== BEGIN SVK PATCH BLOCK ====
Version: svk v2.0.0 (linux)

eJx9VVuP20QUjngjj/wAdJK63UuTtT3jW7LaKJVKpQpokVgQUpdGY3u8cdexE89429V6S9oKqQ/A
AzzwACqCV174Bfw2zthO2BUhjhTP8Zzzne/cZh7kx4djsxyNjFIzjfLzLz8eDj9jMpjeRklzSh7G
Mss1u0z4OU80WibZqWaVKZtx3JUsP+VyNDLR2KuNP6oMViCWwvCZzFKhDSqwicw518zSGw/KMSnH
FE1LEzezOU8neZZJlB3cmSg+QZIJPlF2qDi2lS7RTKtWDuOcB+jsQtGK/QpH2VZq7gY1s5RrJaoc
2I2D6yqmYlVB0A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NaeNJ6zPb7HuNG36Cm0R/4Bul7jk1N6jiDgRn+A2E0ikk=
==== END SVK PATCH BLOCK ====



More information about the svk-devel mailing list