/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/remote.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 05:10:44 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20190304051044-vph4s8p9qvpy2qe9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    UninitializableFormat,
49
49
    )
50
50
from ..revisiontree import RevisionTree
51
 
from ..sixish import text_type
 
51
from ..sixish import (
 
52
    text_type,
 
53
    viewitems,
 
54
    )
52
55
from ..transport import (
53
56
    Transport,
54
57
    register_urlparse_netloc_protocol,
476
479
        refname = self._get_selected_ref(name)
477
480
 
478
481
        def get_changed_refs(old_refs):
479
 
            ret = dict(old_refs)
480
 
            if refname not in ret:
 
482
            ret = {}
 
483
            if refname not in old_refs:
481
484
                raise NotBranchError(self.user_url)
482
485
            ret[refname] = dulwich.client.ZERO_SHA
483
486
            return ret
566
569
        if isinstance(source, GitBranch) and lossy:
567
570
            raise errors.LossyPushToSameVCS(source.controldir, self)
568
571
        source_store = get_object_store(source.repository)
 
572
        fetch_tags = source.get_config_stack().get('branch.fetch_tags')
 
573
        def get_changed_refs(refs):
 
574
            self._refs = remote_refs_dict_to_container(refs)
 
575
            ret = {}
 
576
            # TODO(jelmer): Unpeel if necessary
 
577
            push_result.new_original_revid = revision_id
 
578
            if lossy:
 
579
                new_sha = source_store._lookup_revision_sha1(revision_id)
 
580
            else:
 
581
                try:
 
582
                    new_sha = repo.lookup_bzr_revision_id(revision_id)[0]
 
583
                except errors.NoSuchRevision:
 
584
                    raise errors.NoRoundtrippingSupport(
 
585
                        source, self.open_branch(name=name, nascent_ok=True))
 
586
            if not overwrite:
 
587
                if remote_divergence(ret.get(refname), new_sha,
 
588
                                     source_store):
 
589
                    raise DivergedBranches(
 
590
                        source, self.open_branch(name, nascent_ok=True))
 
591
            ret[refname] = new_sha
 
592
            if fetch_tags:
 
593
                for tagname, revid in viewitems(source.tags.get_tag_dict()):
 
594
                    if lossy:
 
595
                        new_sha = source_store._lookup_revision_sha1(revid)
 
596
                    else:
 
597
                        try:
 
598
                            new_sha = repo.lookup_bzr_revision_id(revid)[0]
 
599
                        except errors.NoSuchRevision:
 
600
                            continue
 
601
                    ret[tag_name_to_ref(tagname)] = new_sha
 
602
            return ret
569
603
        with source_store.lock_read():
570
 
            def get_changed_refs(refs):
571
 
                self._refs = remote_refs_dict_to_container(refs)
572
 
                ret = dict(refs)
573
 
                # TODO(jelmer): Unpeel if necessary
574
 
                push_result.new_original_revid = revision_id
575
 
                if lossy:
576
 
                    new_sha = source_store._lookup_revision_sha1(revision_id)
577
 
                else:
578
 
                    try:
579
 
                        new_sha = repo.lookup_bzr_revision_id(revision_id)[0]
580
 
                    except errors.NoSuchRevision:
581
 
                        raise errors.NoRoundtrippingSupport(
582
 
                            source, self.open_branch(name=name, nascent_ok=True))
583
 
                if not overwrite:
584
 
                    if remote_divergence(ret.get(refname), new_sha,
585
 
                                         source_store):
586
 
                        raise DivergedBranches(
587
 
                            source, self.open_branch(name, nascent_ok=True))
588
 
                ret[refname] = new_sha
589
 
                return ret
590
604
            if lossy:
591
605
                generate_pack_data = source_store.generate_lossy_pack_data
592
606
            else:
660
674
 
661
675
    def __init__(self, transport, *args, **kwargs):
662
676
        self.transport = transport
663
 
        super(BzrGitHttpClient, self).__init__(
664
 
            transport.external_url(), *args, **kwargs)
 
677
        url = urlutils.URL.from_string(transport.external_url())
 
678
        url.user = url.quoted_user = None
 
679
        url.password = url.quoted_password = None
 
680
        super(BzrGitHttpClient, self).__init__(str(url), *args, **kwargs)
665
681
 
666
682
    def _http_request(self, url, headers=None, data=None,
667
683
                      allow_compression=False):
816
832
        f.seek(0)
817
833
        return osutils.file_iterator(f)
818
834
 
819
 
    def is_versioned(self, path, file_id=None):
 
835
    def is_versioned(self, path):
820
836
        raise GitSmartRemoteNotSupported(self.is_versioned, self)
821
837
 
822
838
    def has_filename(self, path):
823
839
        raise GitSmartRemoteNotSupported(self.has_filename, self)
824
840
 
825
 
    def get_file_text(self, path, file_id=None):
 
841
    def get_file_text(self, path):
826
842
        raise GitSmartRemoteNotSupported(self.get_file_text, self)
827
843
 
828
844
 
829
845
class RemoteGitRepository(GitRepository):
830
846
 
 
847
    supports_random_access = False
 
848
 
831
849
    @property
832
850
    def user_url(self):
833
851
        return self.control_url
898
916
        ref = tag_name_to_ref(name)
899
917
 
900
918
        def get_changed_refs(old_refs):
901
 
            ret = dict(old_refs)
902
 
            if sha == dulwich.client.ZERO_SHA and ref not in ret:
 
919
            ret = {}
 
920
            if sha == dulwich.client.ZERO_SHA and ref not in old_refs:
903
921
                raise NoSuchTag(name)
904
922
            ret[ref] = sha
905
923
            return ret