~jelmer/brz/external-patiencediff

« back to all changes in this revision

Viewing changes to breezy/git/remote.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-02-15 15:22:09 UTC
  • mfrom: (7289.1.5 push-branch-tags)
  • Revision ID: breezy.the.bot@gmail.com-20190215152209-3an7d424yyl3dnsb
Fix pushing of tags as part of nascent git branches.

Merged from https://code.launchpad.net/~jelmer/brz/push-branch-tags/+merge/363234

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,
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 = {}
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: