/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/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-21 04:28:46 UTC
  • mfrom: (7494 work)
  • mto: This revision was merged to the branch mainline in revision 7496.
  • Revision ID: jelmer@jelmer.uk-20200221042846-r8lzqu0jetkw772i
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""An adapter between a Git Branch and a Bazaar Branch"""
19
19
 
20
 
from __future__ import absolute_import
21
20
 
 
21
import contextlib
22
22
from io import BytesIO
23
23
from collections import defaultdict
24
24
 
35
35
 
36
36
from .. import (
37
37
    branch,
38
 
    cleanup,
39
38
    config,
40
39
    controldir,
41
40
    errors,
51
50
from ..revision import (
52
51
    NULL_REVISION,
53
52
    )
54
 
from ..sixish import (
55
 
    text_type,
56
 
    viewitems,
57
 
    )
58
53
from ..trace import (
59
54
    is_quiet,
60
55
    mutter,
241
236
                master = None
242
237
            else:
243
238
                master = to_tags.branch.get_master_branch()
244
 
            with cleanup.ExitStack() as es:
 
239
            with contextlib.ExitStack() as es:
245
240
                if master is not None:
246
241
                    es.enter_context(master.lock_write())
247
242
                updates, conflicts = self._merge_to_non_git(
277
272
 
278
273
    def _set_tag_dict(self, to_dict):
279
274
        extra = set(self.refs.allkeys())
280
 
        for k, revid in viewitems(to_dict):
 
275
        for k, revid in to_dict.items():
281
276
            name = tag_name_to_ref(k)
282
277
            if name in extra:
283
278
                extra.remove(name)
798
793
        :return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
799
794
        """
800
795
        refs = self.repository.controldir.get_refs_container()
801
 
        for ref_name, unpeeled in viewitems(refs.as_dict()):
 
796
        for ref_name, unpeeled in refs.as_dict().items():
802
797
            try:
803
798
                tag_name = ref_to_tag_name(ref_name)
804
799
            except (ValueError, UnicodeDecodeError):
806
801
            peeled = refs.get_peeled(ref_name)
807
802
            if peeled is None:
808
803
                peeled = unpeeled
809
 
            if not isinstance(tag_name, text_type):
 
804
            if not isinstance(tag_name, str):
810
805
                raise TypeError(tag_name)
811
806
            yield (ref_name, tag_name, peeled, unpeeled)
812
807
 
1049
1044
        if local and not bound_location:
1050
1045
            raise errors.LocalRequiresBoundBranch()
1051
1046
        source_is_master = False
1052
 
        with cleanup.ExitStack() as es:
 
1047
        with contextlib.ExitStack() as es:
1053
1048
            es.enter_context(self.source.lock_read())
1054
1049
            if bound_location:
1055
1050
                # bound_location comes from a config file, some care has to be
1137
1132
                    raise errors.DivergedBranches(self.source, self.target)
1138
1133
            refs = {self.target.ref: new_ref}
1139
1134
            result.new_revid = stop_revision
1140
 
            for name, sha in viewitems(
1141
 
                    self.source.repository._git.refs.as_dict(b"refs/tags")):
 
1135
            for name, sha in (
 
1136
                    self.source.repository._git.refs.as_dict(b"refs/tags").items()):
1142
1137
                if sha not in self.source.repository._git:
1143
1138
                    trace.mutter('Ignoring missing SHA: %s', sha)
1144
1139
                    continue
1300
1295
        if fetch_tags is None:
1301
1296
            c = self.source.get_config_stack()
1302
1297
            fetch_tags = c.get('branch.fetch_tags')
1303
 
        for name, revid in viewitems(self.source.tags.get_tag_dict()):
 
1298
        for name, revid in self.source.tags.get_tag_dict().items():
1304
1299
            if self.source.repository.has_revision(revid):
1305
1300
                ref = tag_name_to_ref(name)
1306
1301
                if not check_ref_format(ref):
1337
1332
            # updated that hasn't actually been updated.
1338
1333
            return False
1339
1334
        # FIXME: Check for diverged branches
1340
 
        for ref, (git_sha, revid) in viewitems(new_refs):
 
1335
        for ref, (git_sha, revid) in new_refs.items():
1341
1336
            if ref_equals(ret, ref, git_sha, revid):
1342
1337
                # Already up to date
1343
1338
                if git_sha is None:
1374
1369
            stop_revision = self.source.last_revision()
1375
1370
        ret = []
1376
1371
        if fetch_tags:
1377
 
            for k, v in viewitems(self.source.tags.get_tag_dict()):
 
1372
            for k, v in self.source.tags.get_tag_dict().items():
1378
1373
                ret.append((None, v))
1379
1374
        ret.append((None, stop_revision))
1380
1375
        try: