/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-06-12 01:45:56 UTC
  • mfrom: (7513.1.2 pypy3)
  • Revision ID: breezy.the.bot@gmail.com-20200612014556-tsc8assk3d0luziu
Avoid deprecated behaviour in ElementTree.

Merged from https://code.launchpad.net/~jelmer/brz/pypy3/+merge/385611

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,
50
49
from ..revision import (
51
50
    NULL_REVISION,
52
51
    )
53
 
from ..sixish import (
54
 
    text_type,
55
 
    viewitems,
56
 
    )
57
52
from ..tag import (
58
53
    Tags,
59
54
    InterTags,
239
234
            master = None
240
235
        else:
241
236
            master = self.target.branch.get_master_branch()
242
 
        with cleanup.ExitStack() as es:
 
237
        with contextlib.ExitStack() as es:
243
238
            if master is not None:
244
239
                es.enter_context(master.lock_write())
245
240
            updates, conflicts = self._merge_to(
327
322
 
328
323
    def _set_tag_dict(self, to_dict):
329
324
        extra = set(self.refs.allkeys())
330
 
        for k, revid in viewitems(to_dict):
 
325
        for k, revid in to_dict.items():
331
326
            name = tag_name_to_ref(k)
332
327
            if name in extra:
333
328
                extra.remove(name)
849
844
        :return: iterator over (ref_name, tag_name, peeled_sha1, unpeeled_sha1)
850
845
        """
851
846
        refs = self.repository.controldir.get_refs_container()
852
 
        for ref_name, unpeeled in viewitems(refs.as_dict()):
 
847
        for ref_name, unpeeled in refs.as_dict().items():
853
848
            try:
854
849
                tag_name = ref_to_tag_name(ref_name)
855
850
            except (ValueError, UnicodeDecodeError):
857
852
            peeled = refs.get_peeled(ref_name)
858
853
            if peeled is None:
859
854
                peeled = unpeeled
860
 
            if not isinstance(tag_name, text_type):
 
855
            if not isinstance(tag_name, str):
861
856
                raise TypeError(tag_name)
862
857
            yield (ref_name, tag_name, peeled, unpeeled)
863
858
 
1101
1096
        if local and not bound_location:
1102
1097
            raise errors.LocalRequiresBoundBranch()
1103
1098
        source_is_master = False
1104
 
        with cleanup.ExitStack() as es:
 
1099
        with contextlib.ExitStack() as es:
1105
1100
            es.enter_context(self.source.lock_read())
1106
1101
            if bound_location:
1107
1102
                # bound_location comes from a config file, some care has to be
1192
1187
                    raise errors.DivergedBranches(self.source, self.target)
1193
1188
            refs = {self.target.ref: new_ref}
1194
1189
            result.new_revid = stop_revision
1195
 
            for name, sha in viewitems(
1196
 
                    self.source.repository._git.refs.as_dict(b"refs/tags")):
 
1190
            for name, sha in (
 
1191
                    self.source.repository._git.refs.as_dict(b"refs/tags").items()):
1197
1192
                if tag_selector and not tag_selector(name):
1198
1193
                    continue
1199
1194
                if sha not in self.source.repository._git:
1203
1198
            return refs
1204
1199
        self.target.repository.send_pack(
1205
1200
            get_changed_refs,
1206
 
            self.source.repository._git.object_store.generate_pack_data)
 
1201
            self.source.repository._git.generate_pack_data)
1207
1202
        return result
1208
1203
 
1209
1204
 
1358
1353
        if fetch_tags is None:
1359
1354
            c = self.source.get_config_stack()
1360
1355
            fetch_tags = c.get('branch.fetch_tags')
1361
 
        for name, revid in viewitems(self.source.tags.get_tag_dict()):
 
1356
        for name, revid in self.source.tags.get_tag_dict().items():
1362
1357
            if self.source.repository.has_revision(revid):
1363
1358
                ref = tag_name_to_ref(name)
1364
1359
                if not check_ref_format(ref):
1395
1390
            # updated that hasn't actually been updated.
1396
1391
            return False
1397
1392
        # FIXME: Check for diverged branches
1398
 
        for ref, (git_sha, revid) in viewitems(new_refs):
 
1393
        for ref, (git_sha, revid) in new_refs.items():
1399
1394
            if ref_equals(ret, ref, git_sha, revid):
1400
1395
                # Already up to date
1401
1396
                if git_sha is None:
1434
1429
            stop_revision = self.source.last_revision()
1435
1430
        ret = []
1436
1431
        if fetch_tags:
1437
 
            for k, v in viewitems(self.source.tags.get_tag_dict()):
 
1432
            for k, v in self.source.tags.get_tag_dict().items():
1438
1433
                ret.append((None, v))
1439
1434
        ret.append((None, stop_revision))
1440
1435
        try: