git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: "David D. Kilzer" <ddkilzer@kilzer.net>
Cc: git@vger.kernel.org
Subject: [PATCH 4/3] git-svn: allow `info' command to work offline
Date: Wed, 21 Nov 2007 18:23:43 -0800	[thread overview]
Message-ID: <20071122022343.GA9992@soma> (raw)
In-Reply-To: <1195675039-26746-1-git-send-email-ddkilzer@kilzer.net>

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>
---

 David:

 I'll apply this once you've verified my fix to 1/3 is correct behavior,
 too.

 git-svn.perl |   26 +++++++++++++++++++++++---
 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 ",
-- 
Eric Wong

  parent reply	other threads:[~2007-11-22  2:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 19:57 [PATCH 0/3 v3] Implement git-svn info David D. Kilzer
2007-11-21 19:57 ` [PATCH 1/3 v3] git-svn: extract reusable code into utility functions David D. Kilzer
2007-11-21 19:57   ` [PATCH 2/3 v3] git-svn info: implement info command David D. Kilzer
2007-11-21 19:57     ` [PATCH 3/3 v3] git-svn: info --url [path] David D. Kilzer
2007-11-22  1:40     ` [PATCH 2/3 v3] git-svn info: implement info command Eric Wong
2007-11-22  3:16       ` David D. Kilzer
2007-11-22  4:17         ` Eric Wong
2007-11-22  1:19   ` [PATCH 1/3 v3] git-svn: extract reusable code into utility functions Eric Wong
2007-11-22  2:23 ` Eric Wong [this message]
2007-11-22  3:24   ` [PATCH 4/3] git-svn: allow `info' command to work offline Adam Roben
2007-11-22  3:56     ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071122022343.GA9992@soma \
    --to=normalperson@yhbt.net \
    --cc=ddkilzer@kilzer.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).