diff options
author | Marcus Griep <marcus@griep.us> | 2008-08-08 01:41:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-08 16:29:56 -0700 |
commit | 570d35c26dfbc40757da6032cdc96afb58cc0037 (patch) | |
tree | f4214bb8e0404fffde9ae521381d28c4a343adfb /git-svn.perl | |
parent | b47ddefe02945f8746c642219450245cf83ed130 (diff) | |
download | git-570d35c26dfbc40757da6032cdc96afb58cc0037.tar.gz |
git-svn: Allow deep branch names by supporting multi-globs
Some repositories use a deep branching strategy, such as:
branches/1.0/1.0.rc1
branches/1.0/1.0.rc2
branches/1.0/1.0.rtm
branches/1.0/1.0.gold
Only allowing a single glob stiffles this.
This change allows for a single glob 'set' to accept this deep
branching strategy.
The ref glob depth must match the branch glob depth. When using
the -b or -t options for init or clone, this is automatically
done.
For example, using the above branches:
svn-remote.svn.branches = branches/*/*:refs/remote/*/*
gives the following branch names:
1.0/1.0.rc1
1.0/1.0.rc2
1.0/1.0.rtm
1.0/1.0.gold
[ew:
* removed unrelated line-wrapping changes
* fixed line-wrapping in a few more places
* removed trailing whitespace
* fixed bashism in test
* removed unnecessary httpd startup in test
* changed copyright on tests to 2008 Marcus Griep
* added executable permissions to new tests
]
Signed-off-by: Marcus Griep <marcus@griep.us>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-x | git-svn.perl | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/git-svn.perl b/git-svn.perl index 503a7c900a..ee00e417d2 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -987,8 +987,10 @@ sub complete_url_ls_init { if (length $pfx && $pfx !~ m#/$#) { die "--prefix='$pfx' must have a trailing slash '/'\n"; } - command_noisy('config', "svn-remote.$gs->{repo_id}.$n", - "$remote_path:refs/remotes/$pfx*"); + command_noisy('config', + "svn-remote.$gs->{repo_id}.$n", + "$remote_path:refs/remotes/$pfx*" . + ('/*' x (($remote_path =~ tr/*/*/) - 1)) ); } sub verify_ref { @@ -4124,16 +4126,38 @@ sub gs_fetch_loop_common { Git::SVN::gc(); } +sub get_dir_globbed { + my ($self, $left, $depth, $r) = @_; + + my @x = eval { $self->get_dir($left, $r) }; + return unless scalar @x == 3; + my $dirents = $x[0]; + my @finalents; + foreach my $de (keys %$dirents) { + next if $dirents->{$de}->{kind} != $SVN::Node::dir; + if ($depth > 1) { + my @args = ("$left/$de", $depth - 1, $r); + foreach my $dir ($self->get_dir_globbed(@args)) { + push @finalents, "$de/$dir"; + } + } else { + push @finalents, $de; + } + } + @finalents; +} + sub match_globs { my ($self, $exists, $paths, $globs, $r) = @_; sub get_dir_check { my ($self, $exists, $g, $r) = @_; - my @x = eval { $self->get_dir($g->{path}->{left}, $r) }; - return unless scalar @x == 3; - my $dirents = $x[0]; - foreach my $de (keys %$dirents) { - next if $dirents->{$de}->{kind} != $SVN::Node::dir; + + my @dirs = $self->get_dir_globbed($g->{path}->{left}, + $g->{path}->{depth}, + $r); + + foreach my $de (@dirs) { my $p = $g->{path}->full_path($de); next if $exists->{$p}; next if (length $g->{path}->{right} && @@ -4915,16 +4939,20 @@ sub new { my ($class, $glob) = @_; my $re = $glob; $re =~ s!/+$!!g; # no need for trailing slashes - my $nr = $re =~ tr/*/*/; - if ($nr > 1) { - die "Only one '*' wildcard expansion ", - "is supported (got $nr): '$glob'\n"; - } elsif ($nr == 0) { + $re =~ m!^([^*]*)(\*(?:/\*)*)([^*]*)$!; + my $temp = $re; + my ($left, $right) = ($1, $3); + $re = $2; + my $depth = $re =~ tr/*/*/; + if ($depth != $temp =~ tr/*/*/) { + die "Only one set of wildcard directories " . + "(e.g. '*' or '*/*/*') is supported: '$glob'\n"; + } + if ($depth == 0) { die "One '*' is needed for glob: '$glob'\n"; } - $re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g; - my ($left, $right) = ($1, $2); - $re = quotemeta($left) . $re . quotemeta($right); + $re =~ s!\*!\[^/\]*!g; + $re = quotemeta($left) . "($re)" . quotemeta($right); if (length $left && !($left =~ s!/+$!!g)) { die "Missing trailing '/' on left side of: '$glob' ($left)\n"; } @@ -4933,7 +4961,7 @@ sub new { } my $left_re = qr/^\/\Q$left\E(\/|$)/; bless { left => $left, right => $right, left_regex => $left_re, - regex => qr/$re/, glob => $glob }, $class; + regex => qr/$re/, glob => $glob, depth => $depth }, $class; } sub full_path { |