summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-11-22 02:20:57 (GMT)
committerEric Wong <normalperson@yhbt.net>2007-11-22 04:11:11 (GMT)
commita5460eb7bb3ccef599adce87a620a3b89c7eb5df (patch)
treef3f4589d2793c3bb4fc4f3188aa2a2b7131c9256 /git-svn.perl
parent8b014d7157d29ce76b0f631e19c6e2ce9aeb2366 (diff)
downloadgit-a5460eb7bb3ccef599adce87a620a3b89c7eb5df.zip
git-a5460eb7bb3ccef599adce87a620a3b89c7eb5df.tar.gz
git-a5460eb7bb3ccef599adce87a620a3b89c7eb5df.tar.bz2
git-svn: allow `info' command to work offline
Cache the repository root whenever we connect to the repository. This will allow us to notice URL changes if the user changes the URL in .git/config, too. If the repository is no longer accessible, or if `git svn info' is the first and only command run; then '(offline)' will be displayed for "Repository Root:" in the output. Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl26
1 files changed, 23 insertions, 3 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 7d86870..43e1591 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -782,9 +782,14 @@ sub cmd_info {
$result .= "Name: " . basename($path) . "\n" if $file_type ne "dir";
$result .= "URL: " . $full_url . "\n";
- my $repos_root = $gs->ra->{repos_root};
- Git::SVN::remove_username($repos_root);
- $result .= "Repository Root: $repos_root\n";
+ eval {
+ my $repos_root = $gs->repos_root;
+ Git::SVN::remove_username($repos_root);
+ $result .= "Repository Root: $repos_root\n";
+ };
+ if ($@) {
+ $result .= "Repository Root: (offline)\n";
+ }
$result .= "Repository UUID: $uuid\n" unless $diff_status eq "A";
$result .= "Revision: " . ($diff_status eq "A" ? 0 : $rev) . "\n";
@@ -1773,9 +1778,24 @@ sub ra_uuid {
$self->{ra_uuid};
}
+sub _set_repos_root {
+ my ($self, $repos_root) = @_;
+ my $k = "svn-remote.$self->{repo_id}.reposRoot";
+ $repos_root ||= $self->ra->{repos_root};
+ tmp_config($k, $repos_root);
+ $repos_root;
+}
+
+sub repos_root {
+ my ($self) = @_;
+ my $k = "svn-remote.$self->{repo_id}.reposRoot";
+ eval { tmp_config('--get', $k) } || $self->_set_repos_root;
+}
+
sub ra {
my ($self) = shift;
my $ra = Git::SVN::Ra->new($self->{url});
+ $self->_set_repos_root($ra->{repos_root});
if ($self->use_svm_props && !$self->{svm}) {
if ($self->no_metadata) {
die "Can't have both 'noMetadata' and ",