~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to contrib/client-side/svn-clean

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
# svn-clean - Wipes out unversioned files from SVN working copy.
 
4
# Copyright (C) 2004, 2005 Simon Perreault
 
5
#
 
6
# This program is free software; you can redistribute it and/or
 
7
# modify it under the terms of the GNU General Public License
 
8
# as published by the Free Software Foundation; either version 2
 
9
# of the License, or (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program; if not, write to the Free Software
 
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 
 
20
use strict;
 
21
use File::Path;
 
22
use Getopt::Long;
 
23
use Pod::Usage;
 
24
 
 
25
my $force        = 0;
 
26
my $quiet        = 0;
 
27
my $print        = 0;
 
28
my $help         = 0;
 
29
my $man          = 0;
 
30
my $nonrecursive = 0;
 
31
GetOptions(
 
32
    "force"           => \$force,
 
33
    "non-recursive|N" => \$nonrecursive,
 
34
    "quiet"           => \$quiet,
 
35
    "print"           => \$print,
 
36
    "help|?"          => \$help,
 
37
    "man"             => \$man
 
38
  )
 
39
  or pod2usage(2);
 
40
pod2usage(1) if $help;
 
41
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
 
42
 
 
43
# Build svn client command
 
44
my @command = qw(svn status --no-ignore -v);
 
45
if ($nonrecursive) {
 
46
    push @command, '-N';
 
47
}
 
48
 
 
49
# Main file-wiping loop.
 
50
open SVN, "-|", @command, @ARGV
 
51
  or die "Can't call program \"svn\": $!\n";
 
52
while (<SVN>) {
 
53
    if (/^[\?ID]/) {
 
54
        my $file = (split)[-1];
 
55
        if ($print) {
 
56
            print "$file\n";
 
57
        }
 
58
        else {
 
59
            rmtree( $file, !$quiet, !$force );
 
60
            if ( -e $file ) {
 
61
                warn "Could not remove $file: $!\n";
 
62
            }
 
63
        }
 
64
    }
 
65
}
 
66
 
 
67
__END__
 
68
 
 
69
=head1 NAME
 
70
 
 
71
svn-clean - Wipes out unversioned files from Subversion working copy
 
72
 
 
73
=head1 SYNOPSIS
 
74
 
 
75
svn-clean [options] [directory or file ...]
 
76
 
 
77
=head1 DESCRIPTION
 
78
 
 
79
B<svn-clean> will scan the given files and directories recursively and find
 
80
unversioned files and directories (files and directories that are not present in
 
81
the Subversion repository). After the scan is done, these files and directories
 
82
will be deleted.
 
83
 
 
84
If no file or directory is given, B<svn-clean> defaults to the current directory
 
85
(".").
 
86
 
 
87
=head1 OPTIONS
 
88
 
 
89
=over 8
 
90
 
 
91
=item B<-f>, B<--force>
 
92
 
 
93
Files to which you do not have delete access (if running under VMS) or write
 
94
access (if running under another OS) will not be deleted unless you use this
 
95
option.
 
96
 
 
97
=item B<-N>, B<--non-recursive>
 
98
 
 
99
Do not search recursively for unversioned files and directories. Unversioned
 
100
directories will still be deleted along with all their contents.
 
101
 
 
102
=item B<-q>, B<--quiet>
 
103
 
 
104
Do not print progress info. In particular, do not print a message each time a
 
105
file is examined, giving the name of the file, and indicating whether "rmdir" or
 
106
"unlink" is used to remove it, or that it’s skipped.
 
107
 
 
108
=item B<-p>, B<--print>
 
109
 
 
110
Do not delete anything. Instead, print the name of every file and directory that
 
111
would have been deleted.
 
112
 
 
113
=item B<-?>, B<-h>, B<--help>
 
114
 
 
115
Prints a brief help message and exits.
 
116
 
 
117
=item B<--man>
 
118
 
 
119
Prints the manual page and exits.
 
120
 
 
121
=back
 
122
 
 
123
=head1 AUTHOR
 
124
 
 
125
Simon Perreault <nomis80@nomis80.org>
 
126
 
 
127
=cut