summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-02-17 03:15:21 (GMT)
committerEric Wong <normalperson@yhbt.net>2007-02-23 08:57:13 (GMT)
commitaea736cc6db64219b946adb4ca77f5d17bc7ab77 (patch)
tree4b264b0c3377ca909819e4fd6c5c4586ddab2fb8 /git-svn.perl
parent0425ea90889f967c3966ace3e5a85b9a5a44c358 (diff)
downloadgit-aea736cc6db64219b946adb4ca77f5d17bc7ab77.zip
git-aea736cc6db64219b946adb4ca77f5d17bc7ab77.tar.gz
git-aea736cc6db64219b946adb4ca77f5d17bc7ab77.tar.bz2
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>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl26
1 files changed, 25 insertions, 1 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 2cc7c33..3e48c56 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1406,6 +1406,26 @@ sub get_commit_parents {
@ret;
}
+sub rewrite_root {
+ my ($self) = @_;
+ return $self->{-rewrite_root} if exists $self->{-rewrite_root};
+ my $k = "svn-remote.$self->{repo_id}.rewriteRoot";
+ my $rwr = eval { command_oneline(qw/config --get/, $k) };
+ if ($rwr) {
+ $rwr =~ s#/+$##;
+ if ($rwr !~ m#^[a-z\+]+://#) {
+ die "$rwr is not a valid URL (key: $k)\n";
+ }
+ }
+ $self->{-rewrite_root} = $rwr;
+}
+
+sub metadata_url {
+ my ($self) = @_;
+ ($self->rewrite_root || $self->{url}) .
+ (length $self->{path} ? '/' . $self->{path} : '');
+}
+
sub full_url {
my ($self) = @_;
$self->{url} . (length $self->{path} ? '/' . $self->{path} : '');
@@ -1704,6 +1724,10 @@ sub make_log_entry {
my ($name, $email) = defined $::users{$author} ? @{$::users{$author}}
: ($author, undef);
if (defined $headrev && $self->use_svm_props) {
+ if ($self->rewrite_root) {
+ die "Can't have both 'useSvmProps' and 'rewriteRoot' ",
+ "options set!\n";
+ }
my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$};
if ($uuid ne $self->{svm}->{uuid}) {
die "UUID mismatch on SVM path:\n",
@@ -1716,7 +1740,7 @@ sub make_log_entry {
$log_entry{svm_revision} = $r;
$email ||= "$author\@$uuid"
} else {
- $log_entry{metadata} = $self->full_url . "\@$rev " .
+ $log_entry{metadata} = $self->metadata_url. "\@$rev " .
$self->ra->get_uuid;
$email ||= "$author\@" . $self->ra->get_uuid;
}