/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-07 02:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200207021430-m49iq3x4x8xlib6x
Drop python2 support.

Show diffs side-by-side

added added

removed removed

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