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
18
17
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)
84
97
class GitSmartTransport(Transport):
86
99
def __init__(self, url, _client=None):
87
100
Transport.__init__(self, url)
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)
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)
93
106
self._client = _client
95
108
def external_url(self):
107
120
def fetch_pack(self, determine_wants, graph_walker, pack_data, progress=None):
108
121
if progress is None:
109
122
def progress(text):
110
info("git: %s" % text)
123
trace.info("git: %s" % text)
111
124
client = self._get_client(thin_packs=False)
113
126
return client.fetch_pack(self._get_path(), determine_wants,
182
195
def open_repository(self):
183
196
return RemoteGitRepository(self, self._lockfiles)
185
def open_branch(self, ignore_fallbacks=False):
198
def _open_branch(self, name=None, ignore_fallbacks=False,
186
200
repo = self.open_repository()
187
# TODO: Support for multiple branches in one bzrdir in bzrlib!
188
return RemoteGitBranch(self, repo, "HEAD", self._lockfiles)
201
refname = self._branch_name_to_ref(name)
202
return RemoteGitBranch(self, repo, refname, self._lockfiles)
190
204
def open_workingtree(self, recommend_upgrade=False):
191
205
raise NotLocalUrl(self.transport.base)
327
341
if self._ref is not None:
329
343
heads = self.repository.get_refs()
330
if not self.name in heads:
344
if self.name in heads:
345
self._ref = heads[self.name]
346
elif ("refs/heads/" + self.name) in heads:
347
self._ref = heads["refs/heads/" + self.name]
331
349
raise NoSuchRef(self.name)
332
self._ref = heads[self.name]
335
352
def _synchronize_history(self, destination, revision_id):