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
22
from io import BytesIO
37
from ..errors import (
50
UninitializableFormat,
52
from ..revisiontree import RevisionTree
53
from ..sixish import text_type
54
from ..transport import (
56
register_urlparse_netloc_protocol,
61
user_agent_for_github,
75
BareLocalGitControlDirFormat,
78
GitSmartRemoteNotSupported,
81
from .mapping import (
84
from .object_store import (
90
from .repository import (
101
import dulwich.client
102
from dulwich.errors import (
106
from dulwich.pack import (
108
pack_objects_to_data,
110
from dulwich.protocol import ZERO_SHA
111
from dulwich.refs import (
115
from dulwich.repo import (
124
import urllib.parse as urlparse
125
from urllib.parse import splituser, splitnport
128
from urllib import splituser, splitnport
130
# urlparse only supports a limited number of schemes by default
131
register_urlparse_netloc_protocol('git')
132
register_urlparse_netloc_protocol('git+ssh')
134
from dulwich.pack import load_pack_index
137
class GitPushResult(PushResult):
139
def _lookup_revno(self, revid):
141
return _quick_lookup_revno(self.source_branch, self.target_branch,
143
except GitSmartRemoteNotSupported:
148
return self._lookup_revno(self.old_revid)
152
return self._lookup_revno(self.new_revid)
155
# Don't run any tests on GitSmartTransport as it is not intended to be
156
# a full implementation of Transport
157
def get_test_permutations():
161
def split_git_url(url):
165
:return: Tuple with host, port, username, path.
167
(scheme, netloc, loc, _, _) = urlparse.urlsplit(url)
168
path = urlparse.unquote(loc)
169
if path.startswith("/~"):
171
(username, hostport) = splituser(netloc)
172
(host, port) = splitnport(hostport, None)
173
return (host, port, username, path)
176
class RemoteGitError(BzrError):
178
_fmt = "Remote server error: %(msg)s"
181
class HeadUpdateFailed(BzrError):
183
_fmt = ("Unable to update remote HEAD branch. To update the master "
184
"branch, specify the URL %(base_url)s,branch=master.")
186
def __init__(self, base_url):
187
super(HeadUpdateFailed, self).__init__()
188
self.base_url = base_url
191
def parse_git_error(url, message):
192
"""Parse a remote git server error and return a bzr exception.
194
:param url: URL of the remote repository
195
:param message: Message sent by the remote git server
197
message = str(message).strip()
198
if (message.startswith("Could not find Repository ") or
199
message == 'Repository not found.' or
200
(message.startswith('Repository ') and message.endswith(' not found.'))):
201
return NotBranchError(url, message)
202
if message == "HEAD failed to update":
203
base_url, _ = urlutils.split_segment_parameters(url)
204
return HeadUpdateFailed(base_url)
205
if message.startswith('access denied or repository not exported:'):
206
extra, path = message.split(': ', 1)
207
return PermissionDenied(path, extra)
208
if message.endswith('You are not allowed to push code to this project.'):
209
return PermissionDenied(url, message)
210
if message.endswith(' does not appear to be a git repository'):
211
return NotBranchError(url, message)
212
m = re.match(r'Permission to ([^ ]+) denied to ([^ ]+)\.', message)
214
return PermissionDenied(m.group(1), 'denied to %s' % m.group(2))
215
# Don't know, just return it to the user as-is
216
return RemoteGitError(message)
219
class GitSmartTransport(Transport):
221
def __init__(self, url, _client=None):
222
Transport.__init__(self, url)
223
(self._host, self._port, self._username, self._path) = \
225
if 'transport' in debug.debug_flags:
226
trace.mutter('host: %r, user: %r, port: %r, path: %r',
227
self._host, self._username, self._port, self._path)
228
self._client = _client
229
self._stripped_path = self._path.rsplit(",", 1)[0]
231
def external_url(self):
234
def has(self, relpath):
237
def _get_client(self):
238
raise NotImplementedError(self._get_client)
241
return self._stripped_path
244
raise NoSuchFile(path)
246
def abspath(self, relpath):
247
return urlutils.join(self.base, relpath)
249
def clone(self, offset=None):
250
"""See Transport.clone()."""
254
newurl = urlutils.join(self.base, offset)
256
return self.__class__(newurl, self._client)
259
class TCPGitSmartTransport(GitSmartTransport):
263
def _get_client(self):
264
if self._client is not None:
269
# return dulwich.client.LocalGitClient()
270
return dulwich.client.SubprocessGitClient()
271
return dulwich.client.TCPGitClient(self._host, self._port,
272
report_activity=self._report_activity)
275
class SSHSocketWrapper(object):
277
def __init__(self, sock):
280
def read(self, len=None):
281
return self.sock.recv(len)
283
def write(self, data):
284
return self.sock.write(data)
287
return len(select.select([self.sock.fileno()], [], [], 0)[0]) > 0
290
class DulwichSSHVendor(dulwich.client.SSHVendor):
293
from ..transport import ssh
294
self.bzr_ssh_vendor = ssh._get_ssh_vendor()
296
def run_command(self, host, command, username=None, port=None):
297
connection = self.bzr_ssh_vendor.connect_ssh(username=username,
298
password=None, port=port, host=host, command=command)
299
(kind, io_object) = connection.get_sock_or_pipes()
301
return SSHSocketWrapper(io_object)
303
raise AssertionError("Unknown io object kind %r'" % kind)
306
#dulwich.client.get_ssh_vendor = DulwichSSHVendor
309
class SSHGitSmartTransport(GitSmartTransport):
314
path = self._stripped_path
315
if path.startswith("/~/"):
319
def _get_client(self):
320
if self._client is not None:
324
location_config = config.LocationConfig(self.base)
325
client = dulwich.client.SSHGitClient(self._host, self._port, self._username,
326
report_activity=self._report_activity)
327
# Set up alternate pack program paths
328
upload_pack = location_config.get_user_option('git_upload_pack')
330
client.alternative_paths["upload-pack"] = upload_pack
331
receive_pack = location_config.get_user_option('git_receive_pack')
333
client.alternative_paths["receive-pack"] = receive_pack
337
class RemoteGitBranchFormat(GitBranchFormat):
339
def get_format_description(self):
340
return 'Remote Git Branch'
343
def _matchingcontroldir(self):
344
return RemoteGitControlDirFormat()
346
def initialize(self, a_controldir, name=None, repository=None,
347
append_revisions_only=None):
348
raise UninitializableFormat(self)
351
class DefaultProgressReporter(object):
353
_GIT_PROGRESS_PARTIAL_RE = re.compile(r"(.*?): +(\d+)% \((\d+)/(\d+)\)")
354
_GIT_PROGRESS_TOTAL_RE = re.compile(r"(.*?): (\d+)")
356
def __init__(self, pb):
359
def progress(self, text):
360
text = text.rstrip(b"\r\n")
361
text = text.decode('utf-8')
362
if text.lower().startswith('error: '):
363
trace.show_error('git: %s', text[len(b'error: '):])
365
trace.mutter("git: %s", text)
366
g = self._GIT_PROGRESS_PARTIAL_RE.match(text)
368
(text, pct, current, total) = g.groups()
369
self.pb.update(text, int(current), int(total))
371
g = self._GIT_PROGRESS_TOTAL_RE.match(text)
373
(text, total) = g.groups()
374
self.pb.update(text, None, int(total))
376
trace.note("%s", text)
379
class RemoteGitDir(GitDir):
381
def __init__(self, transport, format, client, client_path):
382
self._format = format
383
self.root_transport = transport
384
self.transport = transport
385
self._mode_check_done = None
386
self._client = client
387
self._client_path = client_path
388
self.base = self.root_transport.base
392
def _gitrepository_class(self):
393
return RemoteGitRepository
395
def archive(self, format, committish, write_data, progress=None,
396
write_error=None, subdirs=None, prefix=None):
398
pb = ui.ui_factory.nested_progress_bar()
399
progress = DefaultProgressReporter(pb).progress
402
def progress_wrapper(message):
403
if message.startswith(b"fatal: Unknown archive format \'"):
404
format = message.strip()[len(b"fatal: Unknown archive format '"):-1]
405
raise errors.NoSuchExportFormat(format.decode('ascii'))
406
return progress(message)
408
self._client.archive(
409
self._client_path, committish, write_data, progress_wrapper,
411
format=(format.encode('ascii') if format else None),
413
prefix=(prefix.encode('utf-8') if prefix else None))
414
except GitProtocolError as e:
415
raise parse_git_error(self.transport.external_url(), e)
420
def fetch_pack(self, determine_wants, graph_walker, pack_data,
423
pb = ui.ui_factory.nested_progress_bar()
424
progress = DefaultProgressReporter(pb).progress
428
result = self._client.fetch_pack(
429
self._client_path, determine_wants, graph_walker, pack_data,
431
if result.refs is None:
433
self._refs = remote_refs_dict_to_container(
434
result.refs, result.symrefs)
436
except GitProtocolError as e:
437
raise parse_git_error(self.transport.external_url(), e)
442
def send_pack(self, get_changed_refs, generate_pack_data, progress=None):
444
pb = ui.ui_factory.nested_progress_bar()
445
progress = DefaultProgressReporter(pb).progress
449
def get_changed_refs_wrapper(refs):
450
# TODO(jelmer): This drops symref information
451
self._refs = remote_refs_dict_to_container(refs)
452
return get_changed_refs(refs)
454
return self._client.send_pack(
455
self._client_path, get_changed_refs_wrapper,
456
generate_pack_data, progress)
457
except GitProtocolError as e:
458
raise parse_git_error(self.transport.external_url(), e)
463
def create_branch(self, name=None, repository=None,
464
append_revisions_only=None, ref=None):
465
refname = self._get_selected_ref(name, ref)
466
if refname != b'HEAD' and refname in self.get_refs_container():
467
raise AlreadyBranchError(self.user_url)
468
if refname in self.get_refs_container():
469
ref_chain, unused_sha = self.get_refs_container().follow(self._get_selected_ref(None))
470
if ref_chain[0] == b'HEAD':
471
refname = ref_chain[1]
472
repo = self.open_repository()
473
return RemoteGitBranch(self, repo, refname)
475
def destroy_branch(self, name=None):
476
refname = self._get_selected_ref(name)
477
def get_changed_refs(old_refs):
479
if not refname in ret:
480
raise NotBranchError(self.user_url)
481
ret[refname] = dulwich.client.ZERO_SHA
483
def generate_pack_data(have, want, ofs_delta=False):
484
return pack_objects_to_data([])
485
self.send_pack(get_changed_refs, generate_pack_data)
489
return self.control_url
492
def user_transport(self):
493
return self.root_transport
496
def control_url(self):
497
return self.control_transport.base
500
def control_transport(self):
501
return self.root_transport
503
def open_repository(self):
504
return RemoteGitRepository(self)
506
def open_branch(self, name=None, unsupported=False,
507
ignore_fallbacks=False, ref=None, possible_transports=None,
509
repo = self.open_repository()
510
ref = self._get_selected_ref(name, ref)
512
if not nascent_ok and ref not in self.get_refs_container():
513
raise NotBranchError(self.root_transport.base,
515
except NotGitRepository:
516
raise NotBranchError(self.root_transport.base,
518
ref_chain, unused_sha = self.get_refs_container().follow(ref)
519
return RemoteGitBranch(self, repo, ref_chain[-1])
521
def open_workingtree(self, recommend_upgrade=False):
522
raise NotLocalUrl(self.transport.base)
524
def has_workingtree(self):
527
def get_peeled(self, name):
528
return self.get_refs_container().get_peeled(name)
530
def get_refs_container(self):
531
if self._refs is not None:
533
result = self.fetch_pack(lambda x: None, None,
534
lambda x: None, lambda x: trace.mutter("git: %s" % x))
535
self._refs = remote_refs_dict_to_container(
536
result.refs, result.symrefs)
539
def push_branch(self, source, revision_id=None, overwrite=False,
540
remember=False, create_prefix=False, lossy=False,
542
"""Push the source branch into this ControlDir."""
543
if revision_id is None:
544
# No revision supplied by the user, default to the branch
546
revision_id = source.last_revision()
548
push_result = GitPushResult()
549
push_result.workingtree_updated = None
550
push_result.master_branch = None
551
push_result.source_branch = source
552
push_result.stacked_on = None
553
push_result.branch_push_result = None
554
repo = self.find_repository()
555
refname = self._get_selected_ref(name)
556
if isinstance(source, GitBranch) and lossy:
557
raise errors.LossyPushToSameVCS(source.controldir, self)
558
source_store = get_object_store(source.repository)
559
with source_store.lock_read():
560
def get_changed_refs(refs):
561
self._refs = remote_refs_dict_to_container(refs)
563
# TODO(jelmer): Unpeel if necessary
564
push_result.new_original_revid = revision_id
566
new_sha = source_store._lookup_revision_sha1(revision_id)
569
new_sha = repo.lookup_bzr_revision_id(revision_id)[0]
570
except errors.NoSuchRevision:
571
raise errors.NoRoundtrippingSupport(
572
source, self.open_branch(name=name, nascent_ok=True))
574
if remote_divergence(ret.get(refname), new_sha, source_store):
575
raise DivergedBranches(
576
source, self.open_branch(name, nascent_ok=True))
577
ret[refname] = new_sha
580
generate_pack_data = source_store.generate_lossy_pack_data
582
generate_pack_data = source_store.generate_pack_data
583
new_refs = self.send_pack(get_changed_refs, generate_pack_data)
584
push_result.new_revid = repo.lookup_foreign_revision_id(
587
old_remote = self._refs[refname]
589
old_remote = ZERO_SHA
590
push_result.old_revid = repo.lookup_foreign_revision_id(old_remote)
591
self._refs = remote_refs_dict_to_container(new_refs)
592
push_result.target_branch = self.open_branch(name)
593
if old_remote != ZERO_SHA:
594
push_result.branch_push_result = GitBranchPushResult()
595
push_result.branch_push_result.source_branch = source
596
push_result.branch_push_result.target_branch = push_result.target_branch
597
push_result.branch_push_result.local_branch = None
598
push_result.branch_push_result.master_branch = push_result.target_branch
599
push_result.branch_push_result.old_revid = push_result.old_revid
600
push_result.branch_push_result.new_revid = push_result.new_revid
601
push_result.branch_push_result.new_original_revid = push_result.new_original_revid
602
if source.get_push_location() is None or remember:
603
source.set_push_location(push_result.target_branch.base)
606
def _find_commondir(self):
607
# There is no way to find the commondir, if there is any.
611
class EmptyObjectStoreIterator(dict):
613
def iterobjects(self):
617
class TemporaryPackIterator(Pack):
619
def __init__(self, path, resolve_ext_ref):
620
super(TemporaryPackIterator, self).__init__(
621
path, resolve_ext_ref=resolve_ext_ref)
622
self._idx_load = lambda: self._idx_load_or_generate(self._idx_path)
624
def _idx_load_or_generate(self, path):
625
if not os.path.exists(path):
626
pb = ui.ui_factory.nested_progress_bar()
628
def report_progress(cur, total):
629
pb.update("generating index", cur, total)
630
self.data.create_index(path,
631
progress=report_progress)
634
return load_pack_index(path)
637
if self._idx is not None:
639
os.remove(self._idx_path)
640
if self._data is not None:
642
os.remove(self._data_path)
645
class BzrGitHttpClient(dulwich.client.HttpGitClient):
647
def __init__(self, transport, *args, **kwargs):
648
self.transport = transport
649
super(BzrGitHttpClient, self).__init__(transport.external_url(), *args, **kwargs)
651
def _http_request(self, url, headers=None, data=None,
652
allow_compression=False):
653
"""Perform HTTP request.
655
:param url: Request URL.
656
:param headers: Optional custom headers to override defaults.
657
:param data: Request data.
658
:param allow_compression: Allow GZipped communication.
659
:return: Tuple (`response`, `read`), where response is an `urllib3`
660
response object with additional `content_type` and
661
`redirect_location` properties, and `read` is a consumable read
662
method for the response data.
664
from breezy.transport.http._urllib2_wrappers import Request
665
headers['User-agent'] = user_agent_for_github()
666
headers["Pragma"] = "no-cache"
667
if allow_compression:
668
headers["Accept-Encoding"] = "gzip"
670
headers["Accept-Encoding"] = "identity"
673
('GET' if data is None else 'POST'),
675
accepted_errors=[200, 404])
676
request.follow_redirections = True
678
response = self.transport._perform(request)
680
if response.code == 404:
681
raise NotGitRepository()
682
elif response.code != 200:
683
raise GitProtocolError("unexpected http resp %d for %s" %
684
(response.code, url))
686
# TODO: Optimization available by adding `preload_content=False` to the
687
# request and just passing the `read` method on instead of going via
688
# `BytesIO`, if we can guarantee that the entire response is consumed
689
# before issuing the next to still allow for connection reuse from the
691
if response.getheader("Content-Encoding") == "gzip":
692
read = gzip.GzipFile(fileobj=response).read
696
class WrapResponse(object):
698
def __init__(self, response):
699
self._response = response
700
self.status = response.code
701
self.content_type = response.getheader("Content-Type")
702
self.redirect_location = response.geturl()
705
return self._response.readlines()
708
self._response.close()
710
return WrapResponse(response), read
713
class RemoteGitControlDirFormat(GitControlDirFormat):
714
"""The .git directory control format."""
716
supports_workingtrees = False
719
def _known_formats(self):
720
return set([RemoteGitControlDirFormat()])
722
def get_branch_format(self):
723
return RemoteGitBranchFormat()
725
def is_initializable(self):
728
def is_supported(self):
731
def open(self, transport, _found=None):
732
"""Open this directory.
735
# we dont grok readonly - git isn't integrated with transport.
737
if url.startswith('readonly+'):
738
url = url[len('readonly+'):]
739
scheme = urlparse.urlsplit(transport.external_url())[0]
740
if isinstance(transport, GitSmartTransport):
741
client = transport._get_client()
742
client_path = transport._get_path()
743
elif scheme in ("http", "https"):
744
client = BzrGitHttpClient(transport)
745
client_path, _ = urlutils.split_segment_parameters(transport._path)
746
elif scheme == 'file':
747
client = dulwich.client.LocalGitClient()
748
client_path = transport.local_abspath('.')
750
raise NotBranchError(transport.base)
752
pass # TODO(jelmer): Actually probe for something
753
return RemoteGitDir(transport, self, client, client_path)
755
def get_format_description(self):
756
return "Remote Git Repository"
758
def initialize_on_transport(self, transport):
759
raise UninitializableFormat(self)
761
def supports_transport(self, transport):
763
external_url = transport.external_url()
764
except InProcessTransport:
765
raise NotBranchError(path=transport.base)
766
return (external_url.startswith("http:") or
767
external_url.startswith("https:") or
768
external_url.startswith("git+") or
769
external_url.startswith("git:"))
772
class GitRemoteRevisionTree(RevisionTree):
774
def archive(self, format, name, root=None, subdir=None, force_mtime=None):
775
"""Create an archive of this tree.
777
:param format: Format name (e.g. 'tar')
778
:param name: target file name
779
:param root: Root directory name (or None)
780
:param subdir: Subdirectory to export (or None)
781
:return: Iterator over archive chunks
783
commit = self._repository.lookup_bzr_revision_id(
784
self.get_revision_id())[0]
785
f = tempfile.SpooledTemporaryFile()
786
# git-upload-archive(1) generaly only supports refs. So let's see if we
790
self._repository.controldir.get_refs_container().as_dict().items()}
792
committish = reverse_refs[commit]
794
# No? Maybe the user has uploadArchive.allowUnreachable enabled.
795
# Let's hope for the best.
797
self._repository.archive(
798
format, committish, f.write,
799
subdirs=([subdir] if subdir else None),
800
prefix=(root+'/') if root else '')
802
return osutils.file_iterator(f)
804
def is_versioned(self, path, file_id=None):
805
raise GitSmartRemoteNotSupported(self.is_versioned, self)
807
def has_filename(self, path):
808
raise GitSmartRemoteNotSupported(self.has_filename, self)
810
def get_file_text(self, path, file_id=None):
811
raise GitSmartRemoteNotSupported(self.get_file_text, self)
814
class RemoteGitRepository(GitRepository):
818
return self.control_url
820
def get_parent_map(self, revids):
821
raise GitSmartRemoteNotSupported(self.get_parent_map, self)
823
def archive(self, *args, **kwargs):
824
return self.controldir.archive(*args, **kwargs)
826
def fetch_pack(self, determine_wants, graph_walker, pack_data,
828
return self.controldir.fetch_pack(
829
determine_wants, graph_walker, pack_data, progress)
831
def send_pack(self, get_changed_refs, generate_pack_data):
832
return self.controldir.send_pack(get_changed_refs, generate_pack_data)
834
def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
836
fd, path = tempfile.mkstemp(suffix=".pack")
838
self.fetch_pack(determine_wants, graph_walker,
839
lambda x: os.write(fd, x), progress)
842
if os.path.getsize(path) == 0:
843
return EmptyObjectStoreIterator()
844
return TemporaryPackIterator(path[:-len(".pack")], resolve_ext_ref)
846
def lookup_bzr_revision_id(self, bzr_revid, mapping=None):
847
# This won't work for any round-tripped bzr revisions, but it's a start..
849
return mapping_registry.revision_id_bzr_to_foreign(bzr_revid)
850
except InvalidRevisionId:
851
raise NoSuchRevision(self, bzr_revid)
853
def lookup_foreign_revision_id(self, foreign_revid, mapping=None):
854
"""Lookup a revision id.
858
mapping = self.get_mapping()
859
# Not really an easy way to parse foreign revids here..
860
return mapping.revision_id_foreign_to_bzr(foreign_revid)
862
def revision_tree(self, revid):
863
return GitRemoteRevisionTree(self, revid)
865
def get_revisions(self, revids):
866
raise GitSmartRemoteNotSupported(self.get_revisions, self)
868
def has_revisions(self, revids):
869
raise GitSmartRemoteNotSupported(self.get_revisions, self)
872
class RemoteGitTagDict(GitTags):
874
def set_tag(self, name, revid):
875
sha = self.branch.lookup_bzr_revision_id(revid)[0]
876
self._set_ref(name, sha)
878
def delete_tag(self, name):
879
self._set_ref(name, dulwich.client.ZERO_SHA)
881
def _set_ref(self, name, sha):
882
ref = tag_name_to_ref(name)
883
def get_changed_refs(old_refs):
885
if sha == dulwich.client.ZERO_SHA and ref not in ret:
886
raise NoSuchTag(name)
889
def generate_pack_data(have, want, ofs_delta=False):
890
return pack_objects_to_data([])
891
self.repository.send_pack(get_changed_refs, generate_pack_data)
894
class RemoteGitBranch(GitBranch):
896
def __init__(self, controldir, repository, name):
898
super(RemoteGitBranch, self).__init__(controldir, repository, name,
899
RemoteGitBranchFormat())
901
def last_revision_info(self):
902
raise GitSmartRemoteNotSupported(self.last_revision_info, self)
906
return self.control_url
909
def control_url(self):
912
def revision_id_to_revno(self, revision_id):
913
raise GitSmartRemoteNotSupported(self.revision_id_to_revno, self)
915
def last_revision(self):
916
return self.lookup_foreign_revision_id(self.head)
920
if self._sha is not None:
922
refs = self.controldir.get_refs_container()
923
name = branch_name_to_ref(self.name)
925
self._sha = refs[name]
927
raise NoSuchRef(name, self.repository.user_url, refs)
930
def _synchronize_history(self, destination, revision_id):
931
"""See Branch._synchronize_history()."""
932
destination.generate_revision_history(self.last_revision())
934
def _get_parent_location(self):
937
def get_push_location(self):
940
def set_push_location(self, url):
943
def _iter_tag_refs(self):
944
"""Iterate over the tag refs.
946
:param refs: Refs dictionary (name -> git sha1)
947
:return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
949
refs = self.controldir.get_refs_container()
950
for ref_name, unpeeled in refs.as_dict().items():
952
tag_name = ref_to_tag_name(ref_name)
953
except (ValueError, UnicodeDecodeError):
955
peeled = refs.get_peeled(ref_name)
957
# Let's just hope it's a commit
959
if not isinstance(tag_name, text_type):
960
raise TypeError(tag_name)
961
yield (ref_name, tag_name, peeled, unpeeled)
964
def remote_refs_dict_to_container(refs_dict, symrefs_dict={}):
967
for k, v in refs_dict.items():
972
for name, target in symrefs_dict.items():
973
base[name] = SYMREF + target
974
ret = DictRefsContainer(base)