git-svn: added an --include-path flag
The SVN::Fetcher module is now able to filter for inclusion as well as exclusion (as used by --ignore-path). Also added tests, documentation changes and git completion script. If you have an SVN repository with many top level directories and you only want a git-svn clone of some of them then using --ignore-path is difficult as it requires a very long regexp. In this case it's much easier to filter for inclusion. [ew: remove trailing whitespace] Signed-off-by: Paul Walmsley <pjwhams@gmail.com> Signed-off-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package Git::SVN::Fetcher;
|
||||
use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename
|
||||
@deleted_gpath %added_placeholder $repo_id/;
|
||||
use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs
|
||||
$_placeholder_filename @deleted_gpath %added_placeholder
|
||||
$repo_id/;
|
||||
use strict;
|
||||
use warnings;
|
||||
use SVN::Delta;
|
||||
@ -33,6 +34,10 @@ sub new {
|
||||
my $v = eval { command_oneline('config', '--get', $k) };
|
||||
$self->{ignore_regex} = $v;
|
||||
|
||||
$k = "svn-remote.$repo_id.include-paths";
|
||||
$v = eval { command_oneline('config', '--get', $k) };
|
||||
$self->{include_regex} = $v;
|
||||
|
||||
$k = "svn-remote.$repo_id.preserve-empty-dirs";
|
||||
$v = eval { command_oneline('config', '--get', '--bool', $k) };
|
||||
if ($v && $v eq 'true') {
|
||||
@ -117,11 +122,18 @@ sub in_dot_git {
|
||||
}
|
||||
|
||||
# return value: 0 -- don't ignore, 1 -- ignore
|
||||
# This will also check whether the path is explicitly included
|
||||
sub is_path_ignored {
|
||||
my ($self, $path) = @_;
|
||||
return 1 if in_dot_git($path);
|
||||
return 1 if defined($self->{ignore_regex}) &&
|
||||
$path =~ m!$self->{ignore_regex}!;
|
||||
return 0 if defined($self->{include_regex}) &&
|
||||
$path =~ m!$self->{include_regex}!;
|
||||
return 0 if defined($_include_regex) &&
|
||||
$path =~ m!$_include_regex!;
|
||||
return 1 if defined($self->{include_regex});
|
||||
return 1 if defined($_include_regex);
|
||||
return 0 unless defined($_ignore_regex);
|
||||
return 1 if $path =~ m!$_ignore_regex!o;
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user