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

RE: [CONTRIB] `sfind', a wrapper around `find' that ignores .svn directories

From: James FitzGibbon <jfitzgibbon_at_primustel.ca>
Date: 2005-03-03 18:13:27 CET

A simpler (though much dumber) version, if you're willing to install a
couple of CPAN directories:

--START--use strict;
use warnings;
use File::Find::Rule;
use File::Find::Rule::VCS;
print "$_\n" for
File::Find::Rule->ignore_svn->file->name($ARGV[0])->in('.');
---END---

For what I usually end up using find for in working copies, it does the
trick. And due to the simplicity of File::Find::Rule's interface, it would
be pretty simple to extend if needed.

Thanks

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Eric Hanchrow
Sent: Thursday, March 03, 2005 11:29 AM
To: dev@subversion.tigris.org
Subject: [CONTRIB] `sfind', a wrapper around `find' that ignores .svn
directories

I use this (surprisingly complicated :-( ) script constantly, and have told
Emacs to use it instead of `find'. I suspect it'd be useful for other *nix
svn users too.

I have a sneaking suspicion that it doesn't do the right thing in every
case, but I haven't nailed it down. In any case, it's mighty useful.

    #!/usr/bin/perl -w

    use strict;
    use Data::Dumper;

    # A wrapper around GNU find. It ignores Subversion cache directories,
    # but otherwise acts the same.

    # Subversion includes a similar tool in
    # .../contrib/client-side/wcgrep; it runs a recursive grep, ignoring
    # Subversion cache directories.

    my @files;
    my @expression_bits;

    # Consume find's arguments, one by one. As soon as we see an argument
    # that looks like an expression, then it and every remaining argument
    # are expressions. Until then, all the arguments are files.

    push @files , shift @ARGV while
(@ARGV && $ARGV[0] !~ m{^[-(!]});

    push @expression_bits, shift @ARGV while
(@ARGV);

    # We need to add `-print' if they didn't specify actions. Actions
    # begin with hyphens, so they're easy to recognize ... except they
    # might be buried inside parentheses.

    {
      my @tmp = @expression_bits;

      # Get rid of any trailing right-parens.
      pop @tmp while (@tmp && $tmp[-1] eq ")");

      push @expression_bits, qw(-print)
        unless (@tmp
                && ($tmp[-1] =~ m(^-) # most action arguments begin with a
hyphen.

                    || $tmp[-1] eq ";" # the last argument to `-exec' is
                                       # always a semicolon.
                   ));
    }

    unshift @expression_bits, qw(( -type d -name .svn -prune ) -o);

    # Let's get GNU find if possible
    my $prog = "find";

    if ($^O =~ m(freebsd)i) {
      my $gf = "/usr/local/bin/gfind";
      $prog = $gf if (-x $gf);
    }

    exec ($prog, @files, @expression_bits);

--
Because he pays close attention, a Navy pilot can land a 40,000 lb. aircraft
at 140 miles per hour on a pitching carrier deck, at night, more safely than
the average teenager can cut a bagel.
        -- Paul Graham
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.5.7 - Release Date: 3/1/2005
 
-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.5.7 - Release Date: 3/1/2005
 
-- 
----------------------------------------------------------------------------
This electronic message contains information from Primus Telecommunications
Canada Inc. ("PRIMUS") , which may be legally privileged and confidential.
The information is intended to be for the use of the individual(s) or entity
named above. If you are not the intended recipient, be aware that any
disclosure, copying, distribution or use of the contents of this information
is prohibited. If you have received this electronic message in error, please
notify us by telephone or e-mail (to the number or address above)
immediately. Any views, opinions or advice expressed in this electronic
message are not necessarily the views, opinions or advice of PRIMUS.
It is the responsibility of the recipient to ensure that
any attachments are virus free and PRIMUS bears no responsibility
for any loss or damage arising in any way from the use
thereof.The term "PRIMUS" includes its affiliates.
----------------------------------------------------------------------------
Pour la version en français de ce message, veuillez voir
 http://www.primustel.ca/fr/legal/cs.htm
----------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Mar 3 18:18:46 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.