1
# Copyright (C) 2007-2018 Jelmer Vernooij <jelmer@jelmer.uk>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Remote dirs, repositories and branches."""
19
from __future__ import absolute_import
36
from ..errors import (
48
UninitializableFormat,
50
from ..revisiontree import RevisionTree
51
from ..sixish import text_type
52
from ..transport import (
54
register_urlparse_netloc_protocol,
59
user_agent_for_github,
75
GitSmartRemoteNotSupported,
78
from .mapping import (
81
from .object_store import (
87
from .repository import (
99
from dulwich.errors import (
103
from dulwich.pack import (
105
pack_objects_to_data,
107
from dulwich.protocol import ZERO_SHA
108
from dulwich.refs import (
112
from dulwich.repo import (
120
import urllib.parse as urlparse
121
from urllib.parse import splituser, splitnport
124
from urllib import splituser, splitnport
126
# urlparse only supports a limited number of schemes by default
127
register_urlparse_netloc_protocol('git')
128
register_urlparse_netloc_protocol('git+ssh')
130
from dulwich.pack import load_pack_index
133
class GitPushResult(PushResult):
135
def _lookup_revno(self, revid):
137
return _quick_lookup_revno(self.source_branch, self.target_branch,
139
except GitSmartRemoteNotSupported:
144
return self._lookup_revno(self.old_revid)
148
return self._lookup_revno(self.new_revid)
151
# Don't run any tests on GitSmartTransport as it is not intended to be
152
# a full implementation of Transport
153
def get_test_permutations():
157
def split_git_url(url):
161
:return: Tuple with host, port, username, path.
163
(scheme, netloc, loc, _, _) = urlparse.urlsplit(url)
164
path = urlparse.unquote(loc)
165
if path.startswith("/~"):
167
(username, hostport) = splituser(netloc)
168
(host, port) = splitnport(hostport, None)
169
return (host, port, username, path)
172
class RemoteGitError(BzrError):
174
_fmt = "Remote server error: %(msg)s"
177
class HeadUpdateFailed(BzrError):
179
_fmt = ("Unable to update remote HEAD branch. To update the master "
180
"branch, specify the URL %(base_url)s,branch=master.")
182
def __init__(self, base_url):
183
super(HeadUpdateFailed, self).__init__()
184
self.base_url = base_url
187
def parse_git_error(url, message):
188
"""Parse a remote git server error and return a bzr exception.
190
:param url: URL of the remote repository
191
:param message: Message sent by the remote git server
193
message = str(message).strip()
194
if (message.startswith("Could not find Repository ") or
195
message == 'Repository not found.' or
196
(message.startswith('Repository ') and message.endswith(' not found.'))):
197
return NotBranchError(url, message)
198
if message == "HEAD failed to update":
199
base_url, _ = urlutils.split_segment_parameters(url)
200
return HeadUpdateFailed(base_url)
201
if message.startswith('access denied or repository not exported:'):
202
extra, path = message.split(': ', 1)
203
return PermissionDenied(path, extra)
204
if message.endswith('You are not allowed to push code to this project.'):
205
return PermissionDenied(url, message)
206
if message.endswith(' does not appear to be a git repository'):
207
return NotBranchError(url, message)
208
m = re.match(r'Permission to ([^ ]+) denied to ([^ ]+)\.', message)
210
return PermissionDenied(m.group(1), 'denied to %s' % m.group(2))
211
# Don't know, just return it to the user as-is
212
return RemoteGitError(message)
215
class GitSmartTransport(Transport):
217
def __init__(self, url, _client=None):
218
Transport.__init__(self, url)
219
(self._host, self._port, self._username, self._path) = \
221
if 'transport' in debug.debug_flags:
222
trace.mutter('host: %r, user: %r, port: %r, path: %r',
223
self._host, self._username, self._port, self._path)
224
self._client = _client
225
self._stripped_path = self._path.rsplit(",", 1)[0]
227
def external_url(self):
230
def has(self, relpath):
233
def _get_client(self):
234
raise NotImplementedError(self._get_client)
237
return self._stripped_path
240
raise NoSuchFile(path)
242
def abspath(self, relpath):
243
return urlutils.join(self.base, relpath)
245
def clone(self, offset=None):
246
"""See Transport.clone()."""
250
newurl = urlutils.join(self.base, offset)
252
return self.__class__(newurl, self._client)
255
class TCPGitSmartTransport(GitSmartTransport):
259
def _get_client(self):
260
if self._client is not None:
265
# return dulwich.client.LocalGitClient()
266
return dulwich.client.SubprocessGitClient()
267
return dulwich.client.TCPGitClient(self._host, self._port,
268
report_activity=self._report_activity)
271
class SSHSocketWrapper(object):
273
def __init__(self, sock):
276
def read(self, len=None):
277
return self.sock.recv(len)
279
def write(self, data):
280
return self.sock.write(data)
283
return len(select.select([self.sock.fileno()], [], [], 0)[0]) > 0
286
class DulwichSSHVendor(dulwich.client.SSHVendor):
289
from ..transport import ssh
290
self.bzr_ssh_vendor = ssh._get_ssh_vendor()
292
def run_command(self, host, command, username=None, port=None):
293
connection = self.bzr_ssh_vendor.connect_ssh(username=username,
294
password=None, port=port, host=host, command=command)
295
(kind, io_object) = connection.get_sock_or_pipes()
297
return SSHSocketWrapper(io_object)
299
raise AssertionError("Unknown io object kind %r'" % kind)
302
#dulwich.client.get_ssh_vendor = DulwichSSHVendor
305
class SSHGitSmartTransport(GitSmartTransport):
310
path = self._stripped_path
311
if path.startswith("/~/"):
315
def _get_client(self):
316
if self._client is not None:
320
location_config = config.LocationConfig(self.base)
321
client = dulwich.client.SSHGitClient(self._host, self._port, self._username,
322
report_activity=self._report_activity)
323
# Set up alternate pack program paths
324
upload_pack = location_config.get_user_option('git_upload_pack')
326
client.alternative_paths["upload-pack"] = upload_pack
327
receive_pack = location_config.get_user_option('git_receive_pack')
329
client.alternative_paths["receive-pack"] = receive_pack
333
class RemoteGitBranchFormat(GitBranchFormat):
335
def get_format_description(self):
336
return 'Remote Git Branch'
339
def _matchingcontroldir(self):
340
return RemoteGitControlDirFormat()
342
def initialize(self, a_controldir, name=None, repository=None,
343
append_revisions_only=None):
344
raise UninitializableFormat(self)
347
class DefaultProgressReporter(object):
349
_GIT_PROGRESS_PARTIAL_RE = re.compile(r"(.*?): +(\d+)% \((\d+)/(\d+)\)")
350
_GIT_PROGRESS_TOTAL_RE = re.compile(r"(.*?): (\d+)")
352
def __init__(self, pb):
355
def progress(self, text):
356
text = text.rstrip(b"\r\n")
357
text = text.decode('utf-8')
358
if text.lower().startswith('error: '):
359
trace.show_error('git: %s', text[len(b'error: '):])
361
trace.mutter("git: %s", text)
362
g = self._GIT_PROGRESS_PARTIAL_RE.match(text)
364
(text, pct, current, total) = g.groups()
365
self.pb.update(text, int(current), int(total))
367
g = self._GIT_PROGRESS_TOTAL_RE.match(text)
369
(text, total) = g.groups()
370
self.pb.update(text, None, int(total))
372
trace.note("%s", text)
375
class RemoteGitDir(GitDir):
377
def __init__(self, transport, format, client, client_path):
378
self._format = format
379
self.root_transport = transport
380
self.transport = transport
381
self._mode_check_done = None
382
self._client = client
383
self._client_path = client_path
384
self.base = self.root_transport.base
388
def _gitrepository_class(self):
389
return RemoteGitRepository
391
def archive(self, format, committish, write_data, progress=None,
392
write_error=None, subdirs=None, prefix=None):
394
pb = ui.ui_factory.nested_progress_bar()
395
progress = DefaultProgressReporter(pb).progress
398
def progress_wrapper(message):
399
if message.startswith(b"fatal: Unknown archive format \'"):
400
format = message.strip()[len(b"fatal: Unknown archive format '"):-1]
401
raise errors.NoSuchExportFormat(format.decode('ascii'))
402
return progress(message)
404
self._client.archive(
405
self._client_path, committish, write_data, progress_wrapper,
407
format=(format.encode('ascii') if format else None),
409
prefix=(prefix.encode('utf-8') if prefix else None))
410
except GitProtocolError as e:
411
raise parse_git_error(self.transport.external_url(), e)
416
def fetch_pack(self, determine_wants, graph_walker, pack_data,
419
pb = ui.ui_factory.nested_progress_bar()
420
progress = DefaultProgressReporter(pb).progress
424
result = self._client.fetch_pack(
425
self._client_path, determine_wants, graph_walker, pack_data,
427
if result.refs is None:
429
self._refs = remote_refs_dict_to_container(
430
result.refs, result.symrefs)
432
except GitProtocolError as e:
433
raise parse_git_error(self.transport.external_url(), e)
438
def send_pack(self, get_changed_refs, generate_pack_data, progress=None):
440
pb = ui.ui_factory.nested_progress_bar()
441
progress = DefaultProgressReporter(pb).progress
445
def get_changed_refs_wrapper(refs):
446
# TODO(jelmer): This drops symref information
447
self._refs = remote_refs_dict_to_container(refs)
448
return get_changed_refs(refs)
450
return self._client.send_pack(
451
self._client_path, get_changed_refs_wrapper,
452
generate_pack_data, progress)
453
except GitProtocolError as e:
454
raise parse_git_error(self.transport.external_url(), e)
459
def create_branch(self, name=None, repository=None,
460
append_revisions_only=None, ref=None):
461
refname = self._get_selected_ref(name, ref)
462
if refname != b'HEAD' and refname in self.get_refs_container():
463
raise AlreadyBranchError(self.user_url)
464
if refname in self.get_refs_container():
465
ref_chain, unused_sha = self.get_refs_container().follow(self._get_selected_ref(None))
466
if ref_chain[0] == b'HEAD':
467
refname = ref_chain[1]
468
repo = self.open_repository()
469
return RemoteGitBranch(self, repo, refname)
471
def destroy_branch(self, name=None):
472
refname = self._get_selected_ref(name)
473
def get_changed_refs(old_refs):
475
if not refname in ret:
476
raise NotBranchError(self.user_url)
477
ret[refname] = dulwich.client.ZERO_SHA
479
def generate_pack_data(have, want, ofs_delta=False):
480
return pack_objects_to_data([])
481
self.send_pack(get_changed_refs, generate_pack_data)
485
return self.control_url
488
def user_transport(self):
489
return self.root_transport
492
def control_url(self):
493
return self.control_transport.base
496
def control_transport(self):
497
return self.root_transport
499
def open_repository(self):
500
return RemoteGitRepository(self)
502
def open_branch(self, name=None, unsupported=False,
503
ignore_fallbacks=False, ref=None, possible_transports=None,
505
repo = self.open_repository()
506
ref = self._get_selected_ref(name, ref)
508
if not nascent_ok and ref not in self.get_refs_container():
509
raise NotBranchError(self.root_transport.base,
511
except NotGitRepository:
512
raise NotBranchError(self.root_transport.base,
514
ref_chain, unused_sha = self.get_refs_container().follow(ref)
515
return RemoteGitBranch(self, repo, ref_chain[-1])
517
def open_workingtree(self, recommend_upgrade=False):
518
raise NotLocalUrl(self.transport.base)
520
def has_workingtree(self):
523
def get_peeled(self, name):
524
return self.get_refs_container().get_peeled(name)
526
def get_refs_container(self):
527
if self._refs is not None:
529
result = self.fetch_pack(lambda x: None, None,
530
lambda x: None, lambda x: trace.mutter("git: %s" % x))
531
self._refs = remote_refs_dict_to_container(
532
result.refs, result.symrefs)
535
def push_branch(self, source, revision_id=None, overwrite=False,
536
remember=False, create_prefix=False, lossy=False,
538
"""Push the source branch into this ControlDir."""
539
if revision_id is None:
540
# No revision supplied by the user, default to the branch
542
revision_id = source.last_revision()
544
push_result = GitPushResult()
545
push_result.workingtree_updated = None
546
push_result.master_branch = None
547
push_result.source_branch = source
548
push_result.stacked_on = None
549
push_result.branch_push_result = None
550
repo = self.find_repository()
551
refname = self._get_selected_ref(name)
552
if isinstance(source, GitBranch) and lossy:
553
raise errors.LossyPushToSameVCS(source.controldir, self)
554
source_store = get_object_store(source.repository)
555
with source_store.lock_read():
556
def get_changed_refs(refs):
557
self._refs = remote_refs_dict_to_container(refs)
559
# TODO(jelmer): Unpeel if necessary
560
push_result.new_original_revid = revision_id
562
new_sha = source_store._lookup_revision_sha1(revision_id)
565
new_sha = repo.lookup_bzr_revision_id(revision_id)[0]
566
except errors.NoSuchRevision:
567
raise errors.NoRoundtrippingSupport(
568
source, self.open_branch(name=name, nascent_ok=True))
570
if remote_divergence(ret.get(refname), new_sha, source_store):
571
raise DivergedBranches(
572
source, self.open_branch(name, nascent_ok=True))
573
ret[refname] = new_sha
576
generate_pack_data = source_store.generate_lossy_pack_data
578
generate_pack_data = source_store.generate_pack_data
579
new_refs = self.send_pack(get_changed_refs, generate_pack_data)
580
push_result.new_revid = repo.lookup_foreign_revision_id(
583
old_remote = self._refs[refname]
585
old_remote = ZERO_SHA
586
push_result.old_revid = repo.lookup_foreign_revision_id(old_remote)
587
self._refs = remote_refs_dict_to_container(new_refs)
588
push_result.target_branch = self.open_branch(name)
589
if old_remote != ZERO_SHA:
590
push_result.branch_push_result = GitBranchPushResult()
591
push_result.branch_push_result.source_branch = source
592
push_result.branch_push_result.target_branch = push_result.target_branch
593
push_result.branch_push_result.local_branch = None
594
push_result.branch_push_result.master_branch = push_result.target_branch
595
push_result.branch_push_result.old_revid = push_result.old_revid
596
push_result.branch_push_result.new_revid = push_result.new_revid
597
push_result.branch_push_result.new_original_revid = push_result.new_original_revid
598
if source.get_push_location() is None or remember:
599
source.set_push_location(push_result.target_branch.base)
602
def _find_commondir(self):
603
# There is no way to find the commondir, if there is any.
607
class EmptyObjectStoreIterator(dict):
609
def iterobjects(self):
613
class TemporaryPackIterator(Pack):
615
def __init__(self, path, resolve_ext_ref):
616
super(TemporaryPackIterator, self).__init__(
617
path, resolve_ext_ref=resolve_ext_ref)
618
self._idx_load = lambda: self._idx_load_or_generate(self._idx_path)
620
def _idx_load_or_generate(self, path):
621
if not os.path.exists(path):
622
pb = ui.ui_factory.nested_progress_bar()
624
def report_progress(cur, total):
625
pb.update("generating index", cur, total)
626
self.data.create_index(path,
627
progress=report_progress)
630
return load_pack_index(path)
633
if self._idx is not None:
635
os.remove(self._idx_path)
636
if self._data is not None:
638
os.remove(self._data_path)
641
class BzrGitHttpClient(dulwich.client.HttpGitClient):
643
def __init__(self, transport, *args, **kwargs):
644
self.transport = transport
645
super(BzrGitHttpClient, self).__init__(transport.external_url(), *args, **kwargs)
647
def _http_request(self, url, headers=None, data=None,
648
allow_compression=False):
649
"""Perform HTTP request.
651
:param url: Request URL.
652
:param headers: Optional custom headers to override defaults.
653
:param data: Request data.
654
:param allow_compression: Allow GZipped communication.
655
:return: Tuple (`response`, `read`), where response is an `urllib3`
656
response object with additional `content_type` and
657
`redirect_location` properties, and `read` is a consumable read
658
method for the response data.
660
from breezy.transport.http._urllib2_wrappers import Request
661
headers['User-agent'] = user_agent_for_github()
662
headers["Pragma"] = "no-cache"
663
if allow_compression:
664
headers["Accept-Encoding"] = "gzip"
666
headers["Accept-Encoding"] = "identity"
669
('GET' if data is None else 'POST'),
671
accepted_errors=[200, 404])
672
request.follow_redirections = True
674
response = self.transport._perform(request)
676
if response.code == 404:
677
raise NotGitRepository()
678
elif response.code != 200:
679
raise GitProtocolError("unexpected http resp %d for %s" %
680
(response.code, url))
682
# TODO: Optimization available by adding `preload_content=False` to the
683
# request and just passing the `read` method on instead of going via
684
# `BytesIO`, if we can guarantee that the entire response is consumed
685
# before issuing the next to still allow for connection reuse from the
687
if response.getheader("Content-Encoding") == "gzip":
688
read = gzip.GzipFile(fileobj=response).read
692
class WrapResponse(object):
694
def __init__(self, response):
695
self._response = response
696
self.status = response.code
697
self.content_type = response.getheader("Content-Type")
698
self.redirect_location = response.geturl()
701
return self._response.readlines()
704
self._response.close()
706
return WrapResponse(response), read
709
class RemoteGitControlDirFormat(GitControlDirFormat):
710
"""The .git directory control format."""
712
supports_workingtrees = False
715
def _known_formats(self):
716
return set([RemoteGitControlDirFormat()])
718
def get_branch_format(self):
719
return RemoteGitBranchFormat()
721
def is_initializable(self):
724
def is_supported(self):
727
def open(self, transport, _found=None):
728
"""Open this directory.
731
# we dont grok readonly - git isn't integrated with transport.
733
if url.startswith('readonly+'):
734
url = url[len('readonly+'):]
735
scheme = urlparse.urlsplit(transport.external_url())[0]
736
if isinstance(transport, GitSmartTransport):
737
client = transport._get_client()
738
client_path = transport._get_path()
739
elif scheme in ("http", "https"):
740
client = BzrGitHttpClient(transport)
741
client_path, _ = urlutils.split_segment_parameters(transport._path)
742
elif scheme == 'file':
743
client = dulwich.client.LocalGitClient()
744
client_path = transport.local_abspath('.')
746
raise NotBranchError(transport.base)
748
pass # TODO(jelmer): Actually probe for something
749
return RemoteGitDir(transport, self, client, client_path)
751
def get_format_description(self):
752
return "Remote Git Repository"
754
def initialize_on_transport(self, transport):
755
raise UninitializableFormat(self)
757
def supports_transport(self, transport):
759
external_url = transport.external_url()
760
except InProcessTransport:
761
raise NotBranchError(path=transport.base)
762
return (external_url.startswith("http:") or
763
external_url.startswith("https:") or
764
external_url.startswith("git+") or
765
external_url.startswith("git:"))
768
class GitRemoteRevisionTree(RevisionTree):
770
def archive(self, format, name, root=None, subdir=None, force_mtime=None):
771
"""Create an archive of this tree.
773
:param format: Format name (e.g. 'tar')
774
:param name: target file name
775
:param root: Root directory name (or None)
776
:param subdir: Subdirectory to export (or None)
777
:return: Iterator over archive chunks
779
commit = self._repository.lookup_bzr_revision_id(
780
self.get_revision_id())[0]
781
f = tempfile.SpooledTemporaryFile()
782
# git-upload-archive(1) generaly only supports refs. So let's see if we
786
self._repository.controldir.get_refs_container().as_dict().items()}
788
committish = reverse_refs[commit]
790
# No? Maybe the user has uploadArchive.allowUnreachable enabled.
791
# Let's hope for the best.
793
self._repository.archive(
794
format, committish, f.write,
795
subdirs=([subdir] if subdir else None),
796
prefix=(root+'/') if root else '')
798
return osutils.file_iterator(f)
800
def is_versioned(self, path, file_id=None):
801
raise GitSmartRemoteNotSupported(self.is_versioned, self)
803
def has_filename(self, path):
804
raise GitSmartRemoteNotSupported(self.has_filename, self)
806
def get_file_text(self, path, file_id=None):
807
raise GitSmartRemoteNotSupported(self.get_file_text, self)
810
class RemoteGitRepository(GitRepository):
814
return self.control_url
816
def get_parent_map(self, revids):
817
raise GitSmartRemoteNotSupported(self.get_parent_map, self)
819
def archive(self, *args, **kwargs):
820
return self.controldir.archive(*args, **kwargs)
822
def fetch_pack(self, determine_wants, graph_walker, pack_data,
824
return self.controldir.fetch_pack(
825
determine_wants, graph_walker, pack_data, progress)
827
def send_pack(self, get_changed_refs, generate_pack_data):
828
return self.controldir.send_pack(get_changed_refs, generate_pack_data)
830
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
832
fd, path = tempfile.mkstemp(suffix=".pack")
834
self.fetch_pack(determine_wants, graph_walker,
835
lambda x: os.write(fd, x), progress)
838
if os.path.getsize(path) == 0:
839
return EmptyObjectStoreIterator()
840
return TemporaryPackIterator(path[:-len(".pack")], resolve_ext_ref)
842
def lookup_bzr_revision_id(self, bzr_revid, mapping=None):
843
# This won't work for any round-tripped bzr revisions, but it's a start..
845
return mapping_registry.revision_id_bzr_to_foreign(bzr_revid)
846
except InvalidRevisionId:
847
raise NoSuchRevision(self, bzr_revid)
849
def lookup_foreign_revision_id(self, foreign_revid, mapping=None):
850
"""Lookup a revision id.
854
mapping = self.get_mapping()
855
# Not really an easy way to parse foreign revids here..
856
return mapping.revision_id_foreign_to_bzr(foreign_revid)
858
def revision_tree(self, revid):
859
return GitRemoteRevisionTree(self, revid)
861
def get_revisions(self, revids):
862
raise GitSmartRemoteNotSupported(self.get_revisions, self)
864
def has_revisions(self, revids):
865
raise GitSmartRemoteNotSupported(self.get_revisions, self)
868
class RemoteGitTagDict(GitTags):
870
def set_tag(self, name, revid):
871
sha = self.branch.lookup_bzr_revision_id(revid)[0]
872
self._set_ref(name, sha)
874
def delete_tag(self, name):
875
self._set_ref(name, dulwich.client.ZERO_SHA)
877
def _set_ref(self, name, sha):
878
ref = tag_name_to_ref(name)
879
def get_changed_refs(old_refs):
881
if sha == dulwich.client.ZERO_SHA and ref not in ret:
882
raise NoSuchTag(name)
885
def generate_pack_data(have, want, ofs_delta=False):
886
return pack_objects_to_data([])
887
self.repository.send_pack(get_changed_refs, generate_pack_data)
890
class RemoteGitBranch(GitBranch):
892
def __init__(self, controldir, repository, name):
894
super(RemoteGitBranch, self).__init__(controldir, repository, name,
895
RemoteGitBranchFormat())
897
def last_revision_info(self):
898
raise GitSmartRemoteNotSupported(self.last_revision_info, self)
902
return self.control_url
905
def control_url(self):
908
def revision_id_to_revno(self, revision_id):
909
raise GitSmartRemoteNotSupported(self.revision_id_to_revno, self)
911
def last_revision(self):
912
return self.lookup_foreign_revision_id(self.head)
916
if self._sha is not None:
918
refs = self.controldir.get_refs_container()
919
name = branch_name_to_ref(self.name)
921
self._sha = refs[name]
923
raise NoSuchRef(name, self.repository.user_url, refs)
926
def _synchronize_history(self, destination, revision_id):
927
"""See Branch._synchronize_history()."""
928
destination.generate_revision_history(self.last_revision())
930
def _get_parent_location(self):
933
def get_push_location(self):
936
def set_push_location(self, url):
939
def _iter_tag_refs(self):
940
"""Iterate over the tag refs.
942
:param refs: Refs dictionary (name -> git sha1)
943
:return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
945
refs = self.controldir.get_refs_container()
946
for ref_name, unpeeled in refs.as_dict().items():
948
tag_name = ref_to_tag_name(ref_name)
949
except (ValueError, UnicodeDecodeError):
951
peeled = refs.get_peeled(ref_name)
953
# Let's just hope it's a commit
955
if not isinstance(tag_name, text_type):
956
raise TypeError(tag_name)
957
yield (ref_name, tag_name, peeled, unpeeled)
959
def set_last_revision_info(self, revno, revid):
960
self.generate_revision_history(revid)
962
def generate_revision_history(self, revision_id, last_rev=None,
964
sha = self.lookup_bzr_revision_id(revision_id)[0]
965
def get_changed_refs(old_refs):
966
return {self.ref: sha}
967
def generate_pack_data(have, want, ofs_delta=False):
968
return pack_objects_to_data([])
969
self.repository.send_pack(get_changed_refs, generate_pack_data)
973
def remote_refs_dict_to_container(refs_dict, symrefs_dict={}):
976
for k, v in refs_dict.items():
981
for name, target in symrefs_dict.items():
982
base[name] = SYMREF + target
983
ret = DictRefsContainer(base)