[patch] contrib: support for a 'svn-clean:ignore' dirprop
From: Peter Samuelson <peter_at_p12n.org>
Date: Tue, 6 May 2008 00:12:48 -0500
I love the svn-clean script, I use it _all_ the time. But I'm on a
So this patch implements support for a 'svn-clean:ignore' dir prop,
-- Peter Samuelson | org-tld!p12n!peter | http://p12n.org/ [[[ * contrib/client-side/svn-clean: Support a 'svn-clean:ignore' dir property, containing wildcards, one per line, which svn-clean will not touch even if they are unversioned. Patch by: Peter Samuelson <peter_at_p12n.org> Suggested by: Jonathan Hall <flimzy_at_flimzy.com> ]]] --- a/contrib/client-side/svn-clean +++ b/contrib/client-side/svn-clean @@ -48,10 +48,19 @@ pod2usage( -exitstatus => 0, -verbose => 2 ) if $man; $path = Cwd::abs_path( $ARGV[0] ) if @ARGV; +my %svn_clean_ignore; if ( $use_svn_module ) { # Create SVN client object. No need for connection to remote server. my $ctx = new SVN::Client; + my $ign = $ctx->propget('svn-clean:ignore', $path, undef, 1); + for my $dir (keys %$ign) { + for (split /\n/, $ign->{$dir}) { + for (glob "$dir/$_") { + $svn_clean_ignore{$_} = 1 if -e $_; + } + } + } # Call handler function with status info for each file. $ctx->status( $path, undef, \&clean, !$nonrecursive, 1, 0, 1 ); } @@ -59,8 +68,22 @@ warn "Warning: Not using SVN Perl modules, this might be slow.\n" unless $quiet; - # Build svn client command - my @command = qw(svn status --no-ignore -v); + my @command = qw(svn propget svn-clean:ignore); + push @command, '-R' unless $nonrecursive; + open PG, '-|', @command, @ARGV; + my $dir; + while (<PG>) { + if (s/(.*?) - //) { + $dir = $1; + } + chomp; + for (glob "$dir/$_") { + $svn_clean_ignore{$_} = 1 if -e $_; + } + } + close PG; + + @command = qw(svn status --no-ignore -v); if ($nonrecursive) { push @command, '-N'; } @@ -71,6 +94,7 @@ while (<SVN>) { if (/^([\?ID])/) { my $file = (split)[-1]; + next if $svn_clean_ignore{$file}; if ( $1 eq 'D' ) { next unless -f $file; } @@ -90,6 +114,7 @@ # Main file-wiping function. sub clean { my ( $path, $status ) = @_; + return if $svn_clean_ignore{$path}; # Use relative path for pretty-printing. if ( $path =~ s/^\Q$CWD\E\/?//o ) { @@ -140,7 +165,9 @@ B<svn-clean> will scan the given files and directories recursively and find unversioned files and directories (files and directories that are not present in the Subversion repository). After the scan is done, these files and directories -will be deleted. +will be deleted. Files which match patterns in the I<svn-clean:ignore> dir +property will be spared, much as the I<svn:ignore> property works for B<svn +status>. If no file or directory is given, B<svn-clean> defaults to the current directory (".").
|
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.