Merge git://git.bogomips.org/git-svn

* git://git.bogomips.org/git-svn:
  git-svn: Cache results of running the executable "git config"
  git-svn: Add a svn-remote.<name>.pushurl config key
maint
Junio C Hamano 2011-04-11 09:34:19 -07:00
commit e3fa246551
2 changed files with 31 additions and 3 deletions

View File

@ -648,6 +648,16 @@ svn-remote.<name>.rewriteUUID::
where the original UUID is not available via either useSvmProps where the original UUID is not available via either useSvmProps
or useSvnsyncProps. or useSvnsyncProps.


svn-remote.<name>.pushurl::

Similar to git's 'remote.<name>.pushurl', this key is designed
to be used in cases where 'url' points to an SVN repository
via a read-only transport, to provide an alternate read/write
transport. It is assumed that both keys point to the same
repository. Unlike 'commiturl', 'pushurl' is a base path. If
either 'commiturl' or 'pushurl' could be used, 'commiturl'
takes precedence.

svn.brokenSymlinkWorkaround:: svn.brokenSymlinkWorkaround::
This disables potentially expensive checks to workaround This disables potentially expensive checks to workaround
broken symlinks checked into SVN by broken clients. Set this broken symlinks checked into SVN by broken clients. Set this

View File

@ -59,6 +59,7 @@ use File::Find;
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/; use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
use IPC::Open3; use IPC::Open3;
use Git; use Git;
use Memoize; # core since 5.8.0, Jul 2002


BEGIN { BEGIN {
# import functions from Git into our packages, en masse # import functions from Git into our packages, en masse
@ -72,6 +73,8 @@ BEGIN {
*{"${package}::$_"} = \&{"Git::$_"}; *{"${package}::$_"} = \&{"Git::$_"};
} }
} }
Memoize::memoize 'Git::config';
Memoize::memoize 'Git::config_bool';
} }


my ($SVN); my ($SVN);
@ -528,7 +531,7 @@ sub cmd_dcommit {
$url = eval { command_oneline('config', '--get', $url = eval { command_oneline('config', '--get',
"svn-remote.$gs->{repo_id}.commiturl") }; "svn-remote.$gs->{repo_id}.commiturl") };
if (!$url) { if (!$url) {
$url = $gs->full_url $url = $gs->full_pushurl
} }
} }


@ -676,7 +679,7 @@ sub cmd_branch {
$head ||= 'HEAD'; $head ||= 'HEAD';


my (undef, $rev, undef, $gs) = working_head_info($head); my (undef, $rev, undef, $gs) = working_head_info($head);
my $src = $gs->full_url; my $src = $gs->full_pushurl;


my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}}; my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' }; my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' };
@ -727,7 +730,7 @@ sub cmd_branch {
$url = eval { command_oneline('config', '--get', $url = eval { command_oneline('config', '--get',
"svn-remote.$gs->{repo_id}.commiturl") }; "svn-remote.$gs->{repo_id}.commiturl") };
if (!$url) { if (!$url) {
$url = $remote->{url}; $url = $remote->{pushurl} || $remote->{url};
} }
} }
my $dst = join '/', $url, $lft, $branch_name, ($rgt || ()); my $dst = join '/', $url, $lft, $branch_name, ($rgt || ());
@ -1831,6 +1834,8 @@ sub read_all_remotes {
$r->{$1}->{svm} = {}; $r->{$1}->{svm} = {};
} elsif (m!^(.+)\.url=\s*(.*)\s*$!) { } elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
$r->{$1}->{url} = $2; $r->{$1}->{url} = $2;
} elsif (m!^(.+)\.pushurl=\s*(.*)\s*$!) {
$r->{$1}->{pushurl} = $2;
} elsif (m!^(.+)\.(branches|tags)=$svn_refspec$!) { } elsif (m!^(.+)\.(branches|tags)=$svn_refspec$!) {
my ($remote, $t, $local_ref, $remote_ref) = my ($remote, $t, $local_ref, $remote_ref) =
($1, $2, $3, $4); ($1, $2, $3, $4);
@ -2068,6 +2073,8 @@ sub new {
$self->{url} = command_oneline('config', '--get', $self->{url} = command_oneline('config', '--get',
"svn-remote.$repo_id.url") or "svn-remote.$repo_id.url") or
die "Failed to read \"svn-remote.$repo_id.url\" in config\n"; die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
$self->{pushurl} = eval { command_oneline('config', '--get',
"svn-remote.$repo_id.pushurl") };
$self->rebuild; $self->rebuild;
$self; $self;
} }
@ -2545,6 +2552,15 @@ sub full_url {
$self->{url} . (length $self->{path} ? '/' . $self->{path} : ''); $self->{url} . (length $self->{path} ? '/' . $self->{path} : '');
} }


sub full_pushurl {
my ($self) = @_;
if ($self->{pushurl}) {
return $self->{pushurl} . (length $self->{path} ? '/' .
$self->{path} : '');
} else {
return $self->full_url;
}
}


sub set_commit_header_env { sub set_commit_header_env {
my ($log_entry) = @_; my ($log_entry) = @_;
@ -3197,6 +3213,8 @@ sub has_no_changes {
Memoize::unmemoize 'check_cherry_pick'; Memoize::unmemoize 'check_cherry_pick';
Memoize::unmemoize 'has_no_changes'; Memoize::unmemoize 'has_no_changes';
} }

Memoize::memoize 'Git::SVN::repos_root';
} }


END { END {