Big refactor: *Connection hierarchy
[egit/zawir.git] / org.spearce.jgit / src / org / spearce / jgit / transport / FetchConnection.java
blob9d25b0db0f6dd98867ea3ac35e40344a40d4c6d8
1 /*
2 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
8 * conditions are met:
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
21 * written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org.spearce.jgit.transport;
40 import java.util.Collection;
42 import org.spearce.jgit.errors.TransportException;
43 import org.spearce.jgit.lib.ProgressMonitor;
44 import org.spearce.jgit.lib.Ref;
46 /**
47 * Lists known refs from the remote and copies objects of selected refs.
48 * <p>
49 * A fetch connection typically connects to the <code>git-upload-pack</code>
50 * service running where the remote repository is stored. This provides a
51 * one-way object transfer service to copy objects from the remote repository
52 * into this local repository.
53 * <p>
54 * Instances of a FetchConnection must be created by a {@link Transport} that
55 * implements a specific object transfer protocol that both sides of the
56 * connection understand.
57 * <p>
58 * FetchConnection instances are not thread safe and may be accessed by only one
59 * thread at a time.
61 * @see Transport
63 public interface FetchConnection extends Connection {
64 /**
65 * Fetch objects we don't have but that are reachable from advertised refs.
66 * <p>
67 * Only one call per connection is allowed. Subsequent calls will result in
68 * {@link TransportException}.
69 * </p>
70 * <p>
71 * Implementations are free to use network connections as necessary to
72 * efficiently (for both client and server) transfer objects from the remote
73 * repository into this repository. When possible implementations should
74 * avoid replacing/overwriting/duplicating an object already available in
75 * the local destination repository. Locally available objects and packs
76 * should always be preferred over remotely available objects and packs.
77 * {@link Transport#isFetchThin()} should be honored if applicable.
78 * </p>
80 * @param monitor
81 * progress monitor to inform the end-user about the amount of
82 * work completed, or to indicate cancellation. Implementations
83 * should poll the monitor at regular intervals to look for
84 * cancellation requests from the user.
85 * @param want
86 * one or more refs advertised by this connection that the caller
87 * wants to store locally.
88 * @throws TransportException
89 * objects could not be copied due to a network failure,
90 * protocol error, or error on remote side, or connection was
91 * already used for fetch.
93 public void fetch(final ProgressMonitor monitor, final Collection<Ref> want)
94 throws TransportException;
96 /**
97 * Did the last {@link #fetch(ProgressMonitor, Collection)} get tags?
98 * <p>
99 * Some Git aware transports are able to implicitly grab an annotated tag if
100 * {@link TagOpt#AUTO_FOLLOW} or {@link TagOpt#FETCH_TAGS} was selected and
101 * the object the tag peels to (references) was transferred as part of the
102 * last {@link #fetch(ProgressMonitor, Collection)} call. If it is possible
103 * for such tags to have been included in the transfer this method returns
104 * true, allowing the caller to attempt tag discovery.
105 * <p>
106 * By returning only true/false (and not the actual list of tags obtained)
107 * the transport itself does not need to be aware of whether or not tags
108 * were included in the transfer.
110 * @return true if the last fetch call implicitly included tag objects;
111 * false if tags were not implicitly obtained.
113 public boolean didFetchIncludeTags();