88
156
:param url: Git URL
89
157
:return: Tuple with host, port, username, path.
91
(scheme, netloc, loc, _, _) = urlparse.urlsplit(url)
92
path = urllib.unquote(loc)
159
parsed_url = urlparse.urlparse(url)
160
path = urlparse.unquote(parsed_url.path)
93
161
if path.startswith("/~"):
95
(username, hostport) = urllib.splituser(netloc)
96
(host, port) = urllib.splitnport(hostport, None)
97
return (host, port, username, path)
163
return ((parsed_url.hostname or '', parsed_url.port, parsed_url.username, path))
166
class RemoteGitError(BzrError):
168
_fmt = "Remote server error: %(msg)s"
171
class HeadUpdateFailed(BzrError):
173
_fmt = ("Unable to update remote HEAD branch. To update the master "
174
"branch, specify the URL %(base_url)s,branch=master.")
176
def __init__(self, base_url):
177
super(HeadUpdateFailed, self).__init__()
178
self.base_url = base_url
181
def parse_git_error(url, message):
182
"""Parse a remote git server error and return a bzr exception.
184
:param url: URL of the remote repository
185
:param message: Message sent by the remote git server
187
message = str(message).strip()
188
if (message.startswith("Could not find Repository ")
189
or message == 'Repository not found.'
190
or (message.startswith('Repository ') and
191
message.endswith(' not found.'))):
192
return NotBranchError(url, message)
193
if message == "HEAD failed to update":
194
base_url = urlutils.strip_segment_parameters(url)
195
return HeadUpdateFailed(base_url)
196
if message.startswith('access denied or repository not exported:'):
197
extra, path = message.split(':', 1)
198
return PermissionDenied(path.strip(), extra)
199
if message.endswith('You are not allowed to push code to this project.'):
200
return PermissionDenied(url, message)
201
if message.endswith(' does not appear to be a git repository'):
202
return NotBranchError(url, message)
203
if re.match('(.+) is not a valid repository name',
204
message.splitlines()[0]):
205
return NotBranchError(url, message)
206
m = re.match(r'Permission to ([^ ]+) denied to ([^ ]+)\.', message)
208
return PermissionDenied(m.group(1), 'denied to %s' % m.group(2))
209
# Don't know, just return it to the user as-is
210
return RemoteGitError(message)
213
def parse_git_hangup(url, e):
214
"""Parse the error lines from a git servers stderr on hangup.
216
:param url: URL of the remote repository
217
:param e: A HangupException
219
stderr_lines = getattr(e, 'stderr_lines', None)
222
if all(line.startswith(b'remote: ') for line in stderr_lines):
224
line[len(b'remote: '):] for line in stderr_lines]
225
interesting_lines = [
226
line for line in stderr_lines
227
if line and line.replace(b'=', b'')]
228
if len(interesting_lines) == 1:
229
interesting_line = interesting_lines[0]
230
return parse_git_error(
231
url, interesting_line.decode('utf-8', 'surrogateescape'))
232
return RemoteGitError(
233
b'\n'.join(stderr_lines).decode('utf-8', 'surrogateescape'))
100
236
class GitSmartTransport(Transport):
356
class RemoteGitBranchFormat(GitBranchFormat):
358
def get_format_description(self):
359
return 'Remote Git Branch'
362
def _matchingcontroldir(self):
363
return RemoteGitControlDirFormat()
365
def initialize(self, a_controldir, name=None, repository=None,
366
append_revisions_only=None):
367
raise UninitializableFormat(self)
370
class DefaultProgressReporter(object):
372
_GIT_PROGRESS_PARTIAL_RE = re.compile(r"(.*?): +(\d+)% \((\d+)/(\d+)\)")
373
_GIT_PROGRESS_TOTAL_RE = re.compile(r"(.*?): (\d+)")
375
def __init__(self, pb):
378
def progress(self, text):
379
text = text.rstrip(b"\r\n")
380
text = text.decode('utf-8')
381
if text.lower().startswith('error: '):
382
trace.show_error('git: %s', text[len(b'error: '):])
384
trace.mutter("git: %s", text)
385
g = self._GIT_PROGRESS_PARTIAL_RE.match(text)
387
(text, pct, current, total) = g.groups()
388
self.pb.update(text, int(current), int(total))
390
g = self._GIT_PROGRESS_TOTAL_RE.match(text)
392
(text, total) = g.groups()
393
self.pb.update(text, None, int(total))
395
trace.note("%s", text)
198
398
class RemoteGitDir(GitDir):
200
def __init__(self, transport, lockfiles, format):
400
def __init__(self, transport, format, client, client_path):
201
401
self._format = format
202
402
self.root_transport = transport
203
403
self.transport = transport
204
self._lockfiles = lockfiles
205
404
self._mode_check_done = None
207
def _branch_name_to_ref(self, name, default=None):
208
return branch_name_to_ref(name, default=default)
405
self._client = client
406
self._client_path = client_path
407
self.base = self.root_transport.base
411
def _gitrepository_class(self):
412
return RemoteGitRepository
414
def archive(self, format, committish, write_data, progress=None,
415
write_error=None, subdirs=None, prefix=None):
417
pb = ui.ui_factory.nested_progress_bar()
418
progress = DefaultProgressReporter(pb).progress
421
def progress_wrapper(message):
422
if message.startswith(b"fatal: Unknown archive format \'"):
423
format = message.strip()[len(b"fatal: Unknown archive format '"):-1]
424
raise errors.NoSuchExportFormat(format.decode('ascii'))
425
return progress(message)
427
self._client.archive(
428
self._client_path, committish, write_data, progress_wrapper,
430
format=(format.encode('ascii') if format else None),
432
prefix=(prefix.encode('utf-8') if prefix else None))
433
except HangupException as e:
434
raise parse_git_hangup(self.transport.external_url(), e)
435
except GitProtocolError as e:
436
raise parse_git_error(self.transport.external_url(), e)
441
def fetch_pack(self, determine_wants, graph_walker, pack_data,
444
pb = ui.ui_factory.nested_progress_bar()
445
progress = DefaultProgressReporter(pb).progress
449
result = self._client.fetch_pack(
450
self._client_path, determine_wants, graph_walker, pack_data,
452
if result.refs is None:
454
self._refs = remote_refs_dict_to_container(
455
result.refs, result.symrefs)
457
except HangupException as e:
458
raise parse_git_hangup(self.transport.external_url(), e)
459
except GitProtocolError as e:
460
raise parse_git_error(self.transport.external_url(), e)
465
def send_pack(self, get_changed_refs, generate_pack_data, progress=None):
467
pb = ui.ui_factory.nested_progress_bar()
468
progress = DefaultProgressReporter(pb).progress
472
def get_changed_refs_wrapper(remote_refs):
473
if self._refs is not None:
474
update_refs_container(self._refs, remote_refs)
475
return get_changed_refs(remote_refs)
477
return self._client.send_pack(
478
self._client_path, get_changed_refs_wrapper,
479
generate_pack_data, progress)
480
except HangupException as e:
481
raise parse_git_hangup(self.transport.external_url(), e)
482
except GitProtocolError as e:
483
raise parse_git_error(self.transport.external_url(), e)
488
def create_branch(self, name=None, repository=None,
489
append_revisions_only=None, ref=None):
490
refname = self._get_selected_ref(name, ref)
491
if refname != b'HEAD' and refname in self.get_refs_container():
492
raise AlreadyBranchError(self.user_url)
493
ref_chain, unused_sha = self.get_refs_container().follow(
494
self._get_selected_ref(name))
495
if ref_chain and ref_chain[0] == b'HEAD':
496
refname = ref_chain[1]
497
repo = self.open_repository()
498
return RemoteGitBranch(self, repo, refname)
500
def destroy_branch(self, name=None):
501
refname = self._get_selected_ref(name)
503
def get_changed_refs(old_refs):
505
if refname not in old_refs:
506
raise NotBranchError(self.user_url)
507
ret[refname] = dulwich.client.ZERO_SHA
510
def generate_pack_data(have, want, ofs_delta=False):
511
return pack_objects_to_data([])
512
result = self.send_pack(get_changed_refs, generate_pack_data)
513
if result is not None and not isinstance(result, dict):
514
error = result.ref_status.get(refname)
516
raise RemoteGitError(error)
520
return self.control_url
523
def user_transport(self):
524
return self.root_transport
527
def control_url(self):
528
return self.control_transport.base
531
def control_transport(self):
532
return self.root_transport
210
534
def open_repository(self):
211
return RemoteGitRepository(self, self._lockfiles)
213
def _open_branch(self, name=None, ignore_fallbacks=False,
535
return RemoteGitRepository(self)
537
def get_branch_reference(self, name=None):
538
ref = branch_name_to_ref(name)
539
val = self.get_refs_container().read_ref(ref)
540
if val.startswith(SYMREF):
541
return val[len(SYMREF):]
544
def open_branch(self, name=None, unsupported=False,
545
ignore_fallbacks=False, ref=None, possible_transports=None,
215
547
repo = self.open_repository()
216
refname = self._branch_name_to_ref(name)
217
return RemoteGitBranch(self, repo, refname, self._lockfiles)
548
ref = self._get_selected_ref(name, ref)
550
if not nascent_ok and ref not in self.get_refs_container():
551
raise NotBranchError(
552
self.root_transport.base, controldir=self)
553
except NotGitRepository:
554
raise NotBranchError(self.root_transport.base,
556
ref_chain, unused_sha = self.get_refs_container().follow(ref)
557
return RemoteGitBranch(self, repo, ref_chain[-1])
219
559
def open_workingtree(self, recommend_upgrade=False):
220
560
raise NotLocalUrl(self.transport.base)
562
def has_workingtree(self):
565
def get_peeled(self, name):
566
return self.get_refs_container().get_peeled(name)
568
def get_refs_container(self):
569
if self._refs is not None:
571
result = self.fetch_pack(lambda x: None, None,
573
lambda x: trace.mutter("git: %s" % x))
574
self._refs = remote_refs_dict_to_container(
575
result.refs, result.symrefs)
578
def push_branch(self, source, revision_id=None, overwrite=False,
579
remember=False, create_prefix=False, lossy=False,
580
name=None, tag_selector=None):
581
"""Push the source branch into this ControlDir."""
582
if revision_id is None:
583
# No revision supplied by the user, default to the branch
585
revision_id = source.last_revision()
587
push_result = GitPushResult()
588
push_result.workingtree_updated = None
589
push_result.master_branch = None
590
push_result.source_branch = source
591
push_result.stacked_on = None
592
push_result.branch_push_result = None
593
repo = self.find_repository()
594
refname = self._get_selected_ref(name)
595
ref_chain, old_sha = self.get_refs_container().follow(refname)
597
actual_refname = ref_chain[-1]
599
actual_refname = refname
600
if isinstance(source, GitBranch) and lossy:
601
raise errors.LossyPushToSameVCS(source.controldir, self)
602
source_store = get_object_store(source.repository)
603
fetch_tags = source.get_config_stack().get('branch.fetch_tags')
604
def get_changed_refs(remote_refs):
605
if self._refs is not None:
606
update_refs_container(self._refs, remote_refs)
608
# TODO(jelmer): Unpeel if necessary
609
push_result.new_original_revid = revision_id
611
new_sha = source_store._lookup_revision_sha1(revision_id)
614
new_sha = repo.lookup_bzr_revision_id(revision_id)[0]
615
except errors.NoSuchRevision:
616
raise errors.NoRoundtrippingSupport(
617
source, self.open_branch(name=name, nascent_ok=True))
619
if remote_divergence(old_sha, new_sha, source_store):
620
raise DivergedBranches(
621
source, self.open_branch(name, nascent_ok=True))
622
ret[actual_refname] = new_sha
624
for tagname, revid in source.tags.get_tag_dict().items():
625
if tag_selector and not tag_selector(tagname):
629
new_sha = source_store._lookup_revision_sha1(revid)
631
if source.repository.has_revision(revid):
635
new_sha = repo.lookup_bzr_revision_id(revid)[0]
636
except errors.NoSuchRevision:
638
ret[tag_name_to_ref(tagname)] = new_sha
640
with source_store.lock_read():
641
def generate_pack_data(have, want, progress=None,
643
git_repo = getattr(source.repository, '_git', None)
645
shallow = git_repo.get_shallow()
649
return source_store.generate_lossy_pack_data(
650
have, want, shallow=shallow,
651
progress=progress, ofs_delta=ofs_delta)
653
return source_store.generate_pack_data(
654
have, want, shallow=shallow,
655
progress=progress, ofs_delta=ofs_delta)
657
return source_store.generate_pack_data(
658
have, want, progress=progress, ofs_delta=ofs_delta)
659
dw_result = self.send_pack(get_changed_refs, generate_pack_data)
660
if not isinstance(dw_result, dict):
661
new_refs = dw_result.refs
662
error = dw_result.ref_status.get(actual_refname)
664
raise RemoteGitError(error)
665
for ref, error in dw_result.ref_status.items():
667
trace.warning('unable to open ref %s: %s',
669
else: # dulwich < 0.20.4
671
push_result.new_revid = repo.lookup_foreign_revision_id(
672
new_refs[actual_refname])
673
if old_sha is not None:
674
push_result.old_revid = repo.lookup_foreign_revision_id(old_sha)
676
push_result.old_revid = NULL_REVISION
677
if self._refs is not None:
678
update_refs_container(self._refs, new_refs)
679
push_result.target_branch = self.open_branch(name)
680
if old_sha is not None:
681
push_result.branch_push_result = GitBranchPushResult()
682
push_result.branch_push_result.source_branch = source
683
push_result.branch_push_result.target_branch = (
684
push_result.target_branch)
685
push_result.branch_push_result.local_branch = None
686
push_result.branch_push_result.master_branch = (
687
push_result.target_branch)
688
push_result.branch_push_result.old_revid = push_result.old_revid
689
push_result.branch_push_result.new_revid = push_result.new_revid
690
push_result.branch_push_result.new_original_revid = (
691
push_result.new_original_revid)
692
if source.get_push_location() is None or remember:
693
source.set_push_location(push_result.target_branch.base)
696
def _find_commondir(self):
697
# There is no way to find the commondir, if there is any.
223
701
class EmptyObjectStoreIterator(dict):
262
728
os.remove(self._data_path)
731
class BzrGitHttpClient(dulwich.client.HttpGitClient):
733
def __init__(self, transport, *args, **kwargs):
734
self.transport = transport
735
url = urlutils.URL.from_string(transport.external_url())
736
url.user = url.quoted_user = None
737
url.password = url.quoted_password = None
738
url = urlutils.strip_segment_parameters(str(url))
739
super(BzrGitHttpClient, self).__init__(url, *args, **kwargs)
741
def _http_request(self, url, headers=None, data=None,
742
allow_compression=False):
743
"""Perform HTTP request.
745
:param url: Request URL.
746
:param headers: Optional custom headers to override defaults.
747
:param data: Request data.
748
:param allow_compression: Allow GZipped communication.
749
:return: Tuple (`response`, `read`), where response is an `urllib3`
750
response object with additional `content_type` and
751
`redirect_location` properties, and `read` is a consumable read
752
method for the response data.
754
if is_github_url(url):
755
headers['User-agent'] = user_agent_for_github()
756
headers["Pragma"] = "no-cache"
757
if allow_compression:
758
headers["Accept-Encoding"] = "gzip"
760
headers["Accept-Encoding"] = "identity"
762
response = self.transport.request(
763
('GET' if data is None else 'POST'),
766
headers=headers, retries=8)
768
if response.status == 404:
769
raise NotGitRepository()
770
elif response.status != 200:
771
raise GitProtocolError("unexpected http resp %d for %s" %
772
(response.status, url))
774
# TODO: Optimization available by adding `preload_content=False` to the
775
# request and just passing the `read` method on instead of going via
776
# `BytesIO`, if we can guarantee that the entire response is consumed
777
# before issuing the next to still allow for connection reuse from the
779
if response.getheader("Content-Encoding") == "gzip":
780
read = gzip.GzipFile(fileobj=BytesIO(response.read())).read
784
class WrapResponse(object):
786
def __init__(self, response):
787
self._response = response
788
self.status = response.status
789
self.content_type = response.getheader("Content-Type")
790
self.redirect_location = response._actual.geturl()
793
return self._response.readlines()
798
return WrapResponse(response), read
801
def _git_url_and_path_from_transport(external_url):
802
url = urlutils.strip_segment_parameters(external_url)
803
return urlparse.urlsplit(url)
806
class RemoteGitControlDirFormat(GitControlDirFormat):
807
"""The .git directory control format."""
809
supports_workingtrees = False
812
def _known_formats(self):
813
return set([RemoteGitControlDirFormat()])
815
def get_branch_format(self):
816
return RemoteGitBranchFormat()
819
def repository_format(self):
820
return GitRepositoryFormat()
822
def is_initializable(self):
825
def is_supported(self):
828
def open(self, transport, _found=None):
829
"""Open this directory.
832
split_url = _git_url_and_path_from_transport(transport.external_url())
833
if isinstance(transport, GitSmartTransport):
834
client = transport._get_client()
835
elif split_url.scheme in ("http", "https"):
836
client = BzrGitHttpClient(transport)
837
elif split_url.scheme in ('file', ):
838
client = dulwich.client.LocalGitClient()
840
raise NotBranchError(transport.base)
842
pass # TODO(jelmer): Actually probe for something
843
return RemoteGitDir(transport, self, client, split_url.path)
845
def get_format_description(self):
846
return "Remote Git Repository"
848
def initialize_on_transport(self, transport):
849
raise UninitializableFormat(self)
851
def supports_transport(self, transport):
853
external_url = transport.external_url()
854
except InProcessTransport:
855
raise NotBranchError(path=transport.base)
856
return (external_url.startswith("http:")
857
or external_url.startswith("https:")
858
or external_url.startswith("git+")
859
or external_url.startswith("git:"))
862
class GitRemoteRevisionTree(RevisionTree):
864
def archive(self, format, name, root=None, subdir=None, force_mtime=None):
865
"""Create an archive of this tree.
867
:param format: Format name (e.g. 'tar')
868
:param name: target file name
869
:param root: Root directory name (or None)
870
:param subdir: Subdirectory to export (or None)
871
:return: Iterator over archive chunks
873
commit = self._repository.lookup_bzr_revision_id(
874
self.get_revision_id())[0]
876
f = tempfile.SpooledTemporaryFile()
877
# git-upload-archive(1) generaly only supports refs. So let's see if we
881
self._repository.controldir.get_refs_container().as_dict().items()}
883
committish = reverse_refs[commit]
885
# No? Maybe the user has uploadArchive.allowUnreachable enabled.
886
# Let's hope for the best.
888
self._repository.archive(
889
format, committish, f.write,
890
subdirs=([subdir] if subdir else None),
891
prefix=(root + '/') if root else '')
893
return osutils.file_iterator(f)
895
def is_versioned(self, path):
896
raise GitSmartRemoteNotSupported(self.is_versioned, self)
898
def has_filename(self, path):
899
raise GitSmartRemoteNotSupported(self.has_filename, self)
901
def get_file_text(self, path):
902
raise GitSmartRemoteNotSupported(self.get_file_text, self)
904
def list_files(self, include_root=False, from_dir=None, recursive=True):
905
raise GitSmartRemoteNotSupported(self.list_files, self)
265
908
class RemoteGitRepository(GitRepository):
267
def __init__(self, gitdir, lockfiles):
268
GitRepository.__init__(self, gitdir, lockfiles)
272
def inventories(self):
273
raise GitSmartRemoteNotSupported()
277
raise GitSmartRemoteNotSupported()
281
raise GitSmartRemoteNotSupported()
284
if self._refs is not None:
286
self._refs = self.bzrdir.root_transport.fetch_pack(lambda x: [], None,
287
lambda x: None, lambda x: trace.mutter("git: %s" % x))
910
supports_random_access = False
914
return self.control_url
916
def get_parent_map(self, revids):
917
raise GitSmartRemoteNotSupported(self.get_parent_map, self)
919
def archive(self, *args, **kwargs):
920
return self.controldir.archive(*args, **kwargs)
290
922
def fetch_pack(self, determine_wants, graph_walker, pack_data,
292
return self._transport.fetch_pack(determine_wants, graph_walker,
924
return self.controldir.fetch_pack(
925
determine_wants, graph_walker, pack_data, progress)
295
def send_pack(self, get_changed_refs, generate_pack_contents):
296
return self._transport.send_pack(get_changed_refs, generate_pack_contents)
927
def send_pack(self, get_changed_refs, generate_pack_data):
928
return self.controldir.send_pack(get_changed_refs, generate_pack_data)
298
930
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
300
933
fd, path = tempfile.mkstemp(suffix=".pack")
301
self.fetch_pack(determine_wants, graph_walker,
302
lambda x: os.write(fd, x), progress)
935
self.fetch_pack(determine_wants, graph_walker,
936
lambda x: os.write(fd, x), progress)
304
939
if os.path.getsize(path) == 0:
305
940
return EmptyObjectStoreIterator()
306
941
return TemporaryPackIterator(path[:-len(".pack")], resolve_ext_ref)
308
def lookup_bzr_revision_id(self, bzr_revid):
309
# This won't work for any round-tripped bzr revisions, but it's a start..
943
def lookup_bzr_revision_id(self, bzr_revid, mapping=None):
944
# This won't work for any round-tripped bzr revisions, but it's a
311
947
return mapping_registry.revision_id_bzr_to_foreign(bzr_revid)
312
948
except InvalidRevisionId:
321
957
# Not really an easy way to parse foreign revids here..
322
958
return mapping.revision_id_foreign_to_bzr(foreign_revid)
325
class RemoteGitTagDict(tag.BasicTags):
327
def __init__(self, branch):
329
self.repository = branch.repository
331
def get_tag_dict(self):
333
for k, v in extract_tags(self.repository.get_refs()).iteritems():
334
tags[k] = self.branch.mapping.revision_id_foreign_to_bzr(v)
960
def revision_tree(self, revid):
961
return GitRemoteRevisionTree(self, revid)
963
def get_revisions(self, revids):
964
raise GitSmartRemoteNotSupported(self.get_revisions, self)
966
def has_revisions(self, revids):
967
raise GitSmartRemoteNotSupported(self.get_revisions, self)
970
class RemoteGitTagDict(GitTags):
337
972
def set_tag(self, name, revid):
338
# FIXME: Not supported yet, should do a push of a new ref
339
raise NotImplementedError(self.set_tag)
973
sha = self.branch.lookup_bzr_revision_id(revid)[0]
974
self._set_ref(name, sha)
976
def delete_tag(self, name):
977
self._set_ref(name, dulwich.client.ZERO_SHA)
979
def _set_ref(self, name, sha):
980
ref = tag_name_to_ref(name)
982
def get_changed_refs(old_refs):
984
if sha == dulwich.client.ZERO_SHA and ref not in old_refs:
985
raise NoSuchTag(name)
989
def generate_pack_data(have, want, ofs_delta=False):
990
return pack_objects_to_data([])
991
result = self.repository.send_pack(
992
get_changed_refs, generate_pack_data)
993
if result and not isinstance(result, dict):
994
error = result.ref_status.get(ref)
996
raise RemoteGitError(error)
342
999
class RemoteGitBranch(GitBranch):
344
def __init__(self, bzrdir, repository, name, lockfiles):
1001
def __init__(self, controldir, repository, name):
345
1002
self._sha = None
346
super(RemoteGitBranch, self).__init__(bzrdir, repository, name,
349
def revision_history(self):
350
raise GitSmartRemoteNotSupported()
1003
super(RemoteGitBranch, self).__init__(controldir, repository, name,
1004
RemoteGitBranchFormat())
1006
def last_revision_info(self):
1007
raise GitSmartRemoteNotSupported(self.last_revision_info, self)
1011
return self.control_url
1014
def control_url(self):
1017
def revision_id_to_revno(self, revision_id):
1018
raise GitSmartRemoteNotSupported(self.revision_id_to_revno, self)
352
1020
def last_revision(self):
353
1021
return self.lookup_foreign_revision_id(self.head)
355
def _get_config(self):
356
class EmptyConfig(object):
358
def _get_configobj(self):
359
return config.ConfigObj()
365
1025
if self._sha is not None:
366
1026
return self._sha
367
heads = self.repository.get_refs()
368
name = self.bzrdir._branch_name_to_ref(self.name, "HEAD")
370
self._sha = heads[name]
372
raise NoSuchRef(self.name)
1027
refs = self.controldir.get_refs_container()
1028
name = branch_name_to_ref(self.name)
1030
self._sha = refs[name]
1032
raise NoSuchRef(name, self.repository.user_url, refs)
373
1033
return self._sha
375
1035
def _synchronize_history(self, destination, revision_id):
376
1036
"""See Branch._synchronize_history()."""
377
destination.generate_revision_history(self.last_revision())
1037
if revision_id is None:
1038
revision_id = self.last_revision()
1039
destination.generate_revision_history(revision_id)
1041
def _get_parent_location(self):
379
1044
def get_push_location(self):
382
1047
def set_push_location(self, url):
1050
def _iter_tag_refs(self):
1051
"""Iterate over the tag refs.
1053
:param refs: Refs dictionary (name -> git sha1)
1054
:return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
1056
refs = self.controldir.get_refs_container()
1057
for ref_name, unpeeled in refs.as_dict().items():
1059
tag_name = ref_to_tag_name(ref_name)
1060
except (ValueError, UnicodeDecodeError):
1062
peeled = refs.get_peeled(ref_name)
1064
# Let's just hope it's a commit
1066
if not isinstance(tag_name, str):
1067
raise TypeError(tag_name)
1068
yield (ref_name, tag_name, peeled, unpeeled)
1070
def set_last_revision_info(self, revno, revid):
1071
self.generate_revision_history(revid)
1073
def generate_revision_history(self, revision_id, last_rev=None,
1075
sha = self.lookup_bzr_revision_id(revision_id)[0]
1076
def get_changed_refs(old_refs):
1077
return {self.ref: sha}
1078
def generate_pack_data(have, want, ofs_delta=False):
1079
return pack_objects_to_data([])
1080
result = self.repository.send_pack(
1081
get_changed_refs, generate_pack_data)
1082
if result is not None and not isinstance(result, dict):
1083
error = result.ref_status.get(self.ref)
1085
raise RemoteGitError(error)
1089
def remote_refs_dict_to_container(refs_dict, symrefs_dict={}):
1092
for k, v in refs_dict.items():
1097
for name, target in symrefs_dict.items():
1098
base[name] = SYMREF + target
1099
ret = DictRefsContainer(base)
1100
ret._peeled = peeled
1104
def update_refs_container(container, refs_dict):
1107
for k, v in refs_dict.items():
1112
container._peeled = peeled
1113
container._refs.update(base)