14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
from bzrlib import (
82
def split_git_url(url):
86
:return: Tuple with host, port, username, path.
88
(scheme, netloc, loc, _, _) = urlparse.urlsplit(url)
89
path = urllib.unquote(loc)
90
if path.startswith("/~"):
92
(username, hostport) = urllib.splituser(netloc)
93
(host, port) = urllib.splitnport(hostport, None)
94
return (host, port, username, path)
97
84
class GitSmartTransport(Transport):
99
86
def __init__(self, url, _client=None):
100
87
Transport.__init__(self, url)
101
(self._host, self._port, self._username, self._path) = \
103
if 'transport' in debug.debug_flags:
104
trace.mutter('host: %r, user: %r, port: %r, path: %r',
105
self._host, self._username, self._port, self._path)
88
(scheme, _, loc, _, _) = urlparse.urlsplit(url)
89
hostport, escaped_path = urllib.splithost(loc)
90
self._path = urllib.unquote(escaped_path)
91
(self._username, hostport) = urllib.splituser(hostport)
92
(self._host, self._port) = urllib.splitnport(hostport, None)
106
93
self._client = _client
108
95
def external_url(self):
120
107
def fetch_pack(self, determine_wants, graph_walker, pack_data, progress=None):
121
108
if progress is None:
122
109
def progress(text):
123
trace.info("git: %s" % text)
110
info("git: %s" % text)
124
111
client = self._get_client(thin_packs=False)
126
113
return client.fetch_pack(self._get_path(), determine_wants,
192
179
self._lockfiles = lockfiles
193
180
self._mode_check_done = None
195
def _branch_name_to_ref(self, name):
196
from bzrlib.plugins.git.branch import branch_name_to_ref
197
return branch_name_to_ref(name, default="refs/heads/master")
199
182
def open_repository(self):
200
183
return RemoteGitRepository(self, self._lockfiles)
202
def _open_branch(self, name=None, ignore_fallbacks=False,
185
def open_branch(self, ignore_fallbacks=False):
204
186
repo = self.open_repository()
205
refname = self._branch_name_to_ref(name)
206
return RemoteGitBranch(self, repo, refname, self._lockfiles)
187
# TODO: Support for multiple branches in one bzrdir in bzrlib!
188
return RemoteGitBranch(self, repo, "HEAD", self._lockfiles)
208
190
def open_workingtree(self, recommend_upgrade=False):
209
191
raise NotLocalUrl(self.transport.base)
345
327
if self._ref is not None:
347
329
heads = self.repository.get_refs()
348
if self.name in heads:
349
self._ref = heads[self.name]
350
elif ("refs/heads/" + self.name) in heads:
351
self._ref = heads["refs/heads/" + self.name]
330
if not self.name in heads:
353
331
raise NoSuchRef(self.name)
332
self._ref = heads[self.name]
356
335
def _synchronize_history(self, destination, revision_id):