270
273
raise UninitializableFormat(self)
276
def default_report_progress(text):
277
if text.startswith('error: '):
278
trace.show_error('git: %s', text[len('error: '):])
280
trace.mutter("git: %s" % text)
273
283
class RemoteGitDir(GitDir):
275
285
def __init__(self, transport, format, client, client_path):
289
299
def fetch_pack(self, determine_wants, graph_walker, pack_data, progress=None):
290
300
if progress is None:
292
trace.info("git: %s" % text)
293
def wrap_determine_wants(refs_dict):
294
return determine_wants(refs_dict)
301
progress = default_report_progress
296
result = self._client.fetch_pack(self._client_path, wrap_determine_wants,
303
result = self._client.fetch_pack(self._client_path, determine_wants,
297
304
graph_walker, pack_data, progress)
298
305
if result.refs is None:
300
self._refs = remote_refs_dict_to_container(result.refs)
307
self._refs = remote_refs_dict_to_container(result.refs, result.symrefs)
302
309
except GitProtocolError, e:
303
310
raise parse_git_error(self.transport.external_url(), e)
305
def send_pack(self, get_changed_refs, generate_pack_data):
312
def send_pack(self, get_changed_refs, generate_pack_data, progress=None):
314
progress = default_report_progress
307
317
return self._client.send_pack(self._client_path, get_changed_refs,
318
generate_pack_data, progress)
309
319
except GitProtocolError, e:
310
320
raise parse_git_error(self.transport.external_url(), e)
322
def create_branch(self, name=None, repository=None,
323
append_revisions_only=None, ref=None):
324
refname = self._get_selected_ref(name, ref)
325
if refname != b'HEAD' and refname in self.get_refs_container():
326
raise AlreadyBranchError(self.user_url)
327
if refname in self.get_refs_container():
328
ref_chain, unused_sha = self.get_refs_container().follow(self._get_selected_ref(None))
329
if ref_chain[0] == b'HEAD':
330
refname = ref_chain[1]
331
repo = self.open_repository()
332
return RemoteGitBranch(self, repo, refname)
312
334
def destroy_branch(self, name=None):
313
335
refname = self._get_selected_ref(name)
314
336
def get_changed_refs(old_refs):
341
363
return RemoteGitRepository(self)
343
365
def open_branch(self, name=None, unsupported=False,
344
ignore_fallbacks=False, ref=None, possible_transports=None):
366
ignore_fallbacks=False, ref=None, possible_transports=None,
345
368
repo = self.open_repository()
346
refname = self._get_selected_ref(name, ref)
347
return RemoteGitBranch(self, repo, refname)
369
ref = self._get_selected_ref(name, ref)
370
if not nascent_ok and ref not in self.get_refs_container():
371
raise NotBranchError(self.root_transport.base,
373
ref_chain, unused_sha = self.get_refs_container().follow(ref)
374
return RemoteGitBranch(self, repo, ref_chain[-1])
349
376
def open_workingtree(self, recommend_upgrade=False):
350
377
raise NotLocalUrl(self.transport.base)
358
385
def get_refs_container(self):
359
386
if self._refs is not None:
360
387
return self._refs
361
result = self.fetch_pack(lambda x: [], None,
388
result = self.fetch_pack(lambda x: None, None,
362
389
lambda x: None, lambda x: trace.mutter("git: %s" % x))
363
self._refs = remote_refs_dict_to_container(result.refs)
390
self._refs = remote_refs_dict_to_container(
391
result.refs, result.symrefs)
364
392
return self._refs
622
650
yield (ref_name, tag_name, peeled, unpeeled)
625
def remote_refs_dict_to_container(refs_dict):
653
def remote_refs_dict_to_container(refs_dict, symrefs_dict={}):
628
656
for k, v in refs_dict.iteritems():