63
$sha1 = qr/[a-f\d]{40}/;
64
$sha1_short = qr/[a-f\d]{4,40}/;
65
my ($_stdin, $_help, $_edit,
66
- $_message, $_file,
66
+ $_message, $_file, $_branch_dest,
67
$_template, $_shared,
68
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
69
$_merge, $_strategy, $_dry_run, $_local,
92
'localtime' => \$Git::SVN::_localtime,
93
%remote_opts );
94
95
-my ($_trunk, $_tags, $_branches, $_stdlayout);
95
+my ($_trunk, @_tags, @_branches, $_stdlayout);
96
my %icv;
97
my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared,
98
- 'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags,
99
- 'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix,
98
+ 'trunk|T=s' => \$_trunk, 'tags|t=s@' => \@_tags,
99
+ 'branches|b=s@' => \@_branches, 'prefix=s' => \$_prefix,
100
'stdlayout|s' => \$_stdlayout,
101
'minimize-url|m' => \$Git::SVN::_minimize_url,
102
'no-metadata' => sub { $icv{noMetadata} = 1 },
141
branch => [ \&cmd_branch,
142
'Create a branch in the SVN repository',
143
{ 'message|m=s' => \$_message,
144
+ 'destination|d=s' => \$_branch_dest,
145
'dry-run|n' => \$_dry_run,
146
'tag|t' => \$_tag } ],
147
tag => [ sub { $_tag = 1; cmd_branch(@_) },
148
'Create a tag in the SVN repository',
149
{ 'message|m=s' => \$_message,
150
+ 'destination|d=s' => \$_branch_dest,
151
'dry-run|n' => \$_dry_run } ],
152
'set-tree' => [ \&cmd_set_tree,
153
"Set an SVN repository to a git tree-ish",
367
sub cmd_clone {
368
my ($url, $path) = @_;
369
if (!defined $path &&
368
- (defined $_trunk || defined $_branches || defined $_tags ||
370
+ (defined $_trunk || @_branches || @_tags ||
371
defined $_stdlayout) &&
372
$url !~ m#^[a-z\+]+://#) {
373
$path = $url;
381
sub cmd_init {
382
if (defined $_stdlayout) {
383
$_trunk = 'trunk' if (!defined $_trunk);
382
- $_tags = 'tags' if (!defined $_tags);
383
- $_branches = 'branches' if (!defined $_branches);
384
+ @_tags = 'tags' if (! @_tags);
385
+ @_branches = 'branches' if (! @_branches);
386
}
385
- if (defined $_trunk || defined $_branches || defined $_tags) {
387
+ if (defined $_trunk || @_branches || @_tags) {
388
return cmd_multi_init(@_);
389
}
390
my $url = shift or die "SVN repository location required ",
632
my ($src, $rev, undef, $gs) = working_head_info($head);
633
634
my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
633
- my $glob = $remote->{ $_tag ? 'tags' : 'branches' };
635
+ my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' };
636
+ my $glob;
637
+ if ($#{$allglobs} == 0) {
638
+ $glob = $allglobs->[0];
639
+ } else {
640
+ unless(defined $_branch_dest) {
641
+ die "Multiple ",
642
+ $_tag ? "tag" : "branch",
643
+ " paths defined for Subversion repository.\n",
644
+ "You must specify where you want to create the ",
645
+ $_tag ? "tag" : "branch",
646
+ " with the --destination argument.\n";
647
+ }
648
+ foreach my $g (@{$allglobs}) {
649
+ if ($_branch_dest eq $g->{path}->{left}) {
650
+ $glob = $g;
651
+ last;
652
+ }
653
+ }
654
+ unless (defined $glob) {
655
+ die "Unknown ",
656
+ $_tag ? "tag" : "branch",
657
+ " destination $_branch_dest\n";
658
+ }
659
+ }
660
my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/};
661
my $dst = join '/', $remote->{url}, $lft, $branch_name, ($rgt || ());
662
863
864
sub cmd_multi_init {
865
my $url = shift;
840
- unless (defined $_trunk || defined $_branches || defined $_tags) {
866
+ unless (defined $_trunk || @_branches || @_tags) {
867
usage(1);
868
}
869
888
undef, $trunk_ref);
889
}
890
}
865
- return unless defined $_branches || defined $_tags;
891
+ return unless @_branches || @_tags;
892
my $ra = $url ? Git::SVN::Ra->new($url) : undef;
867
- complete_url_ls_init($ra, $_branches, '--branches/-b', $_prefix);
868
- complete_url_ls_init($ra, $_tags, '--tags/-t', $_prefix . 'tags/');
893
+ foreach my $path (@_branches) {
894
+ complete_url_ls_init($ra, $path, '--branches/-b', $_prefix);
895
+ }
896
+ foreach my $path (@_tags) {
897
+ complete_url_ls_init($ra, $path, '--tags/-t', $_prefix.'tags/');
898
+ }
899
}
900
901
sub cmd_multi_fetch {
1180
die "--prefix='$pfx' must have a trailing slash '/'\n";
1181
}
1182
command_noisy('config',
1183
+ '--add',
1184
"svn-remote.$gs->{repo_id}.$n",
1185
"$remote_path:refs/remotes/$pfx*" .
1186
('/*' x (($remote_path =~ tr/*/*/) - 1)) );
1647
# read the max revs for wildcard expansion (branches/*, tags/*)
1648
foreach my $t (qw/branches tags/) {
1649
defined $remote->{$t} or next;
1619
- push @globs, $remote->{$t};
1650
+ push @globs, @{$remote->{$t}};
1651
+
1652
my $max_rev = eval { tmp_config(qw/--int --get/,
1653
"svn-remote.$repo_id.${t}-maxRev") };
1654
if (defined $max_rev && ($max_rev < $base)) {
1695
} elsif (m!^(.+)\.(branches|tags)=
1696
(.*):refs/remotes/(.+)\s*$/!x) {
1697
my ($p, $g) = ($3, $4);
1666
- my $rs = $r->{$1}->{$2} = {
1667
- t => $2,
1668
- remote => $1,
1669
- path => Git::SVN::GlobSpec->new($p),
1670
- ref => Git::SVN::GlobSpec->new($g) };
1698
+ my $rs = {
1699
+ t => $2,
1700
+ remote => $1,
1701
+ path => Git::SVN::GlobSpec->new($p),
1702
+ ref => Git::SVN::GlobSpec->new($g) };
1703
if (length($rs->{ref}->{right}) != 0) {
1704
die "The '*' glob character must be the last ",
1705
"character of '$g'\n";
1706
}
1707
+ push @{ $r->{$1}->{$2} }, $rs;
1708
}
1709
}
1710
1844
next if defined $repos_root && $repos_root ne $u;
1845
1846
my $fetch = $remotes->{$repo_id}->{fetch} || {};
1814
- foreach (qw/branches tags/) {
1815
- resolve_local_globs($u, $fetch,
1816
- $remotes->{$repo_id}->{$_});
1847
+ foreach my $t (qw/branches tags/) {
1848
+ foreach my $globspec (@{$remotes->{$repo_id}->{$t}}) {
1849
+ resolve_local_globs($u, $fetch, $globspec);
1850
+ }
1851
}
1852
my $p = $path;
1853
my $rwr = rewrite_root({repo_id => $repo_id});