line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Find::Object::Rule::VCS; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
File::Find::Object::Rule::VCS - Exclude files/directories for Version Control |
8
|
|
|
|
|
|
|
Systems |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use File::Find::Object::Rule (); |
13
|
|
|
|
|
|
|
use File::Find::Object::Rule::VCS (); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Find all files smaller than 10k, ignoring version control files |
16
|
|
|
|
|
|
|
my @files = File::Find::Object::Rule->ignore_vcs |
17
|
|
|
|
|
|
|
->file |
18
|
|
|
|
|
|
|
->size('<10Ki') |
19
|
|
|
|
|
|
|
->in( $dir ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Many tools need to be equally useful both on ordinary files, and on code |
24
|
|
|
|
|
|
|
that has been checked out from revision control systems. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
B provides quick and convenient methods to |
27
|
|
|
|
|
|
|
exclude the version control directories of several major Version |
28
|
|
|
|
|
|
|
Control Systems (currently CVS, subversion, and Bazaar). |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
B implements methods to ignore the following: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over 4 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item B |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item B |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item B |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=back |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
In addition, the following version control systems do not create |
43
|
|
|
|
|
|
|
directories in the checkout and do not require the use of any |
44
|
|
|
|
|
|
|
ignore methods |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item B |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item B |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
2
|
|
54036
|
use 5.008; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
82
|
|
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
61
|
2
|
|
|
2
|
|
20
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
2
|
|
2539
|
use UNIVERSAL; |
|
2
|
|
|
|
|
29
|
|
|
2
|
|
|
|
|
11
|
|
64
|
2
|
|
|
2
|
|
54
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
65
|
2
|
|
|
2
|
|
735
|
use Text::Glob 0.08 (); |
|
2
|
|
|
|
|
898
|
|
|
2
|
|
|
|
|
50
|
|
66
|
2
|
|
|
2
|
|
1237
|
use File::Find::Object::Rule (); |
|
2
|
|
|
|
|
24651
|
|
|
2
|
|
|
|
|
55
|
|
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
2
|
|
14
|
use vars qw{$VERSION @ISA @EXPORT}; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
167
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$VERSION = '0.0.3'; |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
2
|
|
13
|
use base 'File::Find::Object::Rule'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1441
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $FFOR = 'File::Find::Object::Rule'; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# In some Windows SVN implementations, it uses _svn instead of |
77
|
|
|
|
|
|
|
# .svn, so use both on Win32. |
78
|
|
|
|
|
|
|
my @svn = ($^O eq 'MSWin32') ? ('.svn', '_svn') : ('.svn'); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
##################################################################### |
81
|
|
|
|
|
|
|
# File::Find::Object::Rule Method Addition |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 ignore_vcs |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Ignore all common version control systems |
88
|
|
|
|
|
|
|
$find->ignore_vcs; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Ignore a specific named version control systems |
91
|
|
|
|
|
|
|
$find->ignore_vcs($name); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Ignore nothing (silent pass-through) |
94
|
|
|
|
|
|
|
$find->ignore_vcs(''); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The C method excludes the files for a named Version Control |
97
|
|
|
|
|
|
|
System from your L search. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
If passed, the name of the version control system is case in-sensitive. |
100
|
|
|
|
|
|
|
Names currently supported are 'cvs', 'svn', 'subversion', 'bzr', and |
101
|
|
|
|
|
|
|
'bazaar'. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
As a convenience for high-level APIs, if the VCS name is the defined |
104
|
|
|
|
|
|
|
null string B<''> then the call will be treated as a nullop. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
If no params at all are passed, this method will ignore all supported |
107
|
|
|
|
|
|
|
version control systems. If ignoring every version control system, |
108
|
|
|
|
|
|
|
please note that any legitimate directories called "CVS" or files |
109
|
|
|
|
|
|
|
starting with .# will be ignored, which is not always desirable. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
In widely-distributed code, you instead should try to detect the specific |
112
|
|
|
|
|
|
|
version control system used and call ignore_vcs with the specific name. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Passing C, or an unsupported name, will throw an exception. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub File::Find::Object::Rule::ignore_vcs { |
119
|
4
|
|
|
4
|
0
|
1167
|
my $find = $_[0]->_force_object; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# Handle special cases |
122
|
4
|
50
|
|
|
|
109
|
unless ( @_ ) { |
123
|
|
|
|
|
|
|
# Logically combine all the ignores. This will be much |
124
|
|
|
|
|
|
|
# faster than just calling them all one after the other. |
125
|
0
|
|
|
|
|
0
|
return $find->or( |
126
|
|
|
|
|
|
|
$FFOR->name(@svn, '.bzr', '.git', 'CVS')->directory->prune->discard, |
127
|
|
|
|
|
|
|
$FFOR->name(qr/^\.\#/)->file->discard, |
128
|
|
|
|
|
|
|
$FFOR->new, |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
} |
131
|
4
|
50
|
|
|
|
10
|
unless ( defined $_[1] ) { |
132
|
0
|
|
|
|
|
0
|
Carp::croak("->ignore_vcs: No version control system name provided"); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# As a convenience for higher-level APIs |
136
|
|
|
|
|
|
|
# we treat a defined null string as a nullop |
137
|
4
|
|
|
|
|
11
|
my $vcs = lc $_[1]; |
138
|
4
|
100
|
|
|
|
17
|
return $find if $vcs eq ''; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Hand off to the rules for each VCS |
141
|
3
|
100
|
|
|
|
11
|
return $find->ignore_cvs if $vcs eq 'cvs'; |
142
|
2
|
100
|
|
|
|
9
|
return $find->ignore_svn if $vcs eq 'svn'; |
143
|
1
|
50
|
|
|
|
5
|
return $find->ignore_svn if $vcs eq 'subversion'; |
144
|
1
|
50
|
|
|
|
5
|
return $find->ignore_bzr if $vcs eq 'bzr'; |
145
|
0
|
0
|
|
|
|
0
|
return $find->ignore_bzr if $vcs eq 'bazaar'; |
146
|
0
|
0
|
|
|
|
0
|
return $find->ignore_git if $vcs eq 'git'; |
147
|
0
|
|
|
|
|
0
|
Carp::croak("->ignore_vcs: '$vcs' is not supported"); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=pod |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 ignore_cvs |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The C method excluding all CVS directories from your |
155
|
|
|
|
|
|
|
L search. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
It will also exclude all the files left around by CVS after an |
158
|
|
|
|
|
|
|
automated merge that start with C<'.#'> (dot-hash). |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub File::Find::Object::Rule::ignore_cvs { |
163
|
2
|
|
|
2
|
0
|
2609
|
my $find = $_[0]->_force_object; |
164
|
2
|
|
|
|
|
20
|
return $find->or( |
165
|
|
|
|
|
|
|
$FFOR->name('CVS')->directory->prune->discard, |
166
|
|
|
|
|
|
|
$FFOR->name(qr/^\.\#/)->file->discard, |
167
|
|
|
|
|
|
|
$FFOR->new, |
168
|
|
|
|
|
|
|
); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=pod |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 ignore_svn |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
The C method excluding all Subversion (C<.svn>) directories |
176
|
|
|
|
|
|
|
from your L search. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub File::Find::Object::Rule::ignore_svn { |
181
|
2
|
|
|
2
|
0
|
501
|
my $find = $_[0]->_force_object; |
182
|
2
|
|
|
|
|
16
|
return $find->or( |
183
|
|
|
|
|
|
|
$FFOR->name(@svn)->directory->prune->discard, |
184
|
|
|
|
|
|
|
$FFOR->new, |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=pod |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 ignore_bzr |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
The C method excluding all Bazaar (C<.bzr>) directories |
193
|
|
|
|
|
|
|
from your L search. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub File::Find::Object::Rule::ignore_bzr { |
198
|
2
|
|
|
2
|
0
|
317
|
my $find = $_[0]->_force_object; |
199
|
2
|
|
|
|
|
17
|
return $find->or( |
200
|
|
|
|
|
|
|
$FFOR->name('.bzr')->directory->prune->discard, |
201
|
|
|
|
|
|
|
$FFOR->new, |
202
|
|
|
|
|
|
|
); |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=pod |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head2 ignore_git |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
The C method excluding all Git (C<.git>) directories |
210
|
|
|
|
|
|
|
from your L search. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub File::Find::Object::Rule::ignore_git { |
215
|
0
|
|
|
0
|
0
|
|
my $find = $_[0]->_force_object; |
216
|
0
|
|
|
|
|
|
return $find->or( |
217
|
|
|
|
|
|
|
$FFOR->name('.git')->directory->prune->discard, |
218
|
|
|
|
|
|
|
$FFOR->new, |
219
|
|
|
|
|
|
|
); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
1; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=pod |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 TO DO |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
- Add support for other version control systems. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
- Add other useful VCS-related methods |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 SUPPORT |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Bugs should always be submitted via the CPAN bug tracker |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
L |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
For other issues, contact the maintainer |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head1 AUTHOR |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 ORIGINAL AUTHOR |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head2 MAINTAINER |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Shlomi Fish, L |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 SEE ALSO |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
L, L |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Note: this code originated from Adam Kennedy's L |
255
|
|
|
|
|
|
|
and was span-off/forked with his permission. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 COPYRIGHT |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Copyright 2005 - 2009 Adam Kennedy. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This program is free software; you can redistribute |
262
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
The full text of the license can be found in the |
265
|
|
|
|
|
|
|
LICENSE file included with this module. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head2 Modification Disclaimer |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Modified by Shlomi Fish, 2009. All rights disclaimed. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=cut |