@matheusbsbs / matheus-bagliano / commits / aea736cc6d
Fork 0

git-svn: allow overriding of the SVN repo root in metadata

This feature allows users to create repositories from alternate URLs. For example, an administrator could run git-svn on the server locally (accessing via file://) but wish to distribute the repository with a public http:// or svn:// URL in the metadata so users of it will see the public URL. Config key: svn-remote.<remote>.rewriteRoot Signed-off-by: Eric Wong <normalperson@yhbt.net>

Eric Wong committed Feb 16, 2007 at 19:15 UTC aea736cc6db64219b946adb4ca77f5d17bc7ab77
1 file changed +25 -1
git-svn.perl
+25 -1
@@ -1406,6 +1406,26 @@ sub get_commit_parents {
1406 @ret;
1407 }
1408
1409 +sub rewrite_root {
1410 + my ($self) = @_;
1411 + return $self->{-rewrite_root} if exists $self->{-rewrite_root};
1412 + my $k = "svn-remote.$self->{repo_id}.rewriteRoot";
1413 + my $rwr = eval { command_oneline(qw/config --get/, $k) };
1414 + if ($rwr) {
1415 + $rwr =~ s#/+$##;
1416 + if ($rwr !~ m#^[a-z\+]+://#) {
1417 + die "$rwr is not a valid URL (key: $k)\n";
1418 + }
1419 + }
1420 + $self->{-rewrite_root} = $rwr;
1421 +}
1422 +
1423 +sub metadata_url {
1424 + my ($self) = @_;
1425 + ($self->rewrite_root || $self->{url}) .
1426 + (length $self->{path} ? '/' . $self->{path} : '');
1427 +}
1428 +
1429 sub full_url {
1430 my ($self) = @_;
1431 $self->{url} . (length $self->{path} ? '/' . $self->{path} : '');
@@ -1704,6 +1724,10 @@ sub make_log_entry {
1724 my ($name, $email) = defined $::users{$author} ? @{$::users{$author}}
1725 : ($author, undef);
1726 if (defined $headrev && $self->use_svm_props) {
1727 + if ($self->rewrite_root) {
1728 + die "Can't have both 'useSvmProps' and 'rewriteRoot' ",
1729 + "options set!\n";
1730 + }
1731 my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$};
1732 if ($uuid ne $self->{svm}->{uuid}) {
1733 die "UUID mismatch on SVM path:\n",
@@ -1716,7 +1740,7 @@ sub make_log_entry {
1740 $log_entry{svm_revision} = $r;
1741 $email ||= "$author\@$uuid"
1742 } else {
1719 - $log_entry{metadata} = $self->full_url . "\@$rev " .
1743 + $log_entry{metadata} = $self->metadata_url. "\@$rev " .
1744 $self->ra->get_uuid;
1745 $email ||= "$author\@" . $self->ra->get_uuid;
1746 }