diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-03-07 15:01:49 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-03-13 16:23:56 -0700 |
commit | 305a8ac45f350580957743b3b3aa4c4eca0a6396 (patch) | |
tree | 0fa60016c38e6c93fcd233111a94a65f705839dd /org.eclipse.jgit/src/org/eclipse/jgit/api | |
parent | 2a137d8dea69128cbe03ed2dab77ac5cc4f9c475 (diff) | |
download | jgit-305a8ac45f350580957743b3b3aa4c4eca0a6396.tar.gz jgit-305a8ac45f350580957743b3b3aa4c4eca0a6396.zip |
Make the supported Transports extensible and discoverable
The new TransportProtocol type describes what a particular Transport
implementation wants in order to support a connection. 3rd parties
can now plug into the Transport.open() logic by implementing their
own TransportProtocol and Transport classes, and registering with
Transport.register().
GUI applications can help the user configure a connection by looking
at the supported fields of a particular TransportProtocol type, which
makes the GUI more dynamic and may better support new Transports.
Change-Id: Iafd8e3a6285261412aac6cba8e2c333f8b7b76a5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java | 33 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidRemoteException.java | 10 |
2 files changed, 27 insertions, 16 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java index 9594dfebe7..51dc5295fa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java @@ -50,6 +50,7 @@ import java.util.List; import org.eclipse.jgit.JGitText; import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.errors.NoRemoteRepositoryException; import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.lib.Constants; @@ -121,27 +122,29 @@ public class FetchCommand extends GitCommand<FetchResult> { try { Transport transport = Transport.open(repo, remote); - transport.setCheckFetchedObjects(checkFetchedObjects); - transport.setRemoveDeletedRefs(removeDeletedRefs); - transport.setTimeout(timeout); - transport.setDryRun(dryRun); - if (tagOption != null) - transport.setTagOpt(tagOption); - transport.setFetchThin(thin); - if (credentialsProvider != null) - transport.setCredentialsProvider(credentialsProvider); - try { + transport.setCheckFetchedObjects(checkFetchedObjects); + transport.setRemoveDeletedRefs(removeDeletedRefs); + transport.setTimeout(timeout); + transport.setDryRun(dryRun); + if (tagOption != null) + transport.setTagOpt(tagOption); + transport.setFetchThin(thin); + if (credentialsProvider != null) + transport.setCredentialsProvider(credentialsProvider); + FetchResult result = transport.fetch(monitor, refSpecs); return result; - - } catch (TransportException e) { - throw new JGitInternalException( - JGitText.get().exceptionCaughtDuringExecutionOfFetchCommand, - e); } finally { transport.close(); } + } catch (NoRemoteRepositoryException e) { + throw new InvalidRemoteException(MessageFormat.format( + JGitText.get().invalidRemote, remote), e); + } catch (TransportException e) { + throw new JGitInternalException( + JGitText.get().exceptionCaughtDuringExecutionOfFetchCommand, + e); } catch (URISyntaxException e) { throw new InvalidRemoteException(MessageFormat.format( JGitText.get().invalidRemote, remote)); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidRemoteException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidRemoteException.java index 4104fd669b..3f059b79c7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidRemoteException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidRemoteException.java @@ -44,9 +44,17 @@ public class InvalidRemoteException extends GitAPIException { private static final long serialVersionUID = 1L; /** - * @param msg + * @param msg message describing the invalid remote. */ public InvalidRemoteException(String msg) { super(msg); } + + /** + * @param msg message describing the invalid remote. + * @param cause why the remote is invalid. + */ + public InvalidRemoteException(String msg, Throwable cause) { + super(msg, cause); + } } |