/breezy/trunk

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/trunk

« back to all changes in this revision

Viewing changes to breezy/bzr/versionedfile.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-02-14 03:16:54 UTC
  • mfrom: (7479.2.3 no-more-python2)
  • Revision ID: breezy.the.bot@gmail.com-20200214031654-bp1xtv2jr9nmhto3
Drop python2 support.

Merged from https://code.launchpad.net/~jelmer/brz/no-more-python2/+merge/378694

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from __future__ import absolute_import
20
20
 
21
21
from copy import copy
 
22
from io import BytesIO
22
23
import itertools
23
24
import os
24
25
import struct
46
47
    errors,
47
48
    )
48
49
from ..registry import Registry
49
 
from ..sixish import (
50
 
    BytesIO,
51
 
    viewitems,
52
 
    viewvalues,
53
 
    zip,
54
 
    )
55
50
from ..textmerge import TextMerge
56
51
 
57
52
 
327
322
        refcounts = {}
328
323
        setdefault = refcounts.setdefault
329
324
        just_parents = set()
330
 
        for child_key, parent_keys in viewitems(parent_map):
 
325
        for child_key, parent_keys in parent_map.items():
331
326
            if not parent_keys:
332
327
                # parent_keys may be None if a given VersionedFile claims to
333
328
                # not support graph operations.
1179
1174
            this_parent_map = self.get_parent_map(pending)
1180
1175
            parent_map.update(this_parent_map)
1181
1176
            pending = set(itertools.chain.from_iterable(
1182
 
                viewvalues(this_parent_map)))
 
1177
                this_parent_map.values()))
1183
1178
            pending.difference_update(parent_map)
1184
1179
        kg = _mod_graph.KnownGraph(parent_map)
1185
1180
        return kg
1393
1388
        """
1394
1389
        prefixes = self._partition_keys(keys)
1395
1390
        result = {}
1396
 
        for prefix, suffixes in viewitems(prefixes):
 
1391
        for prefix, suffixes in prefixes.items():
1397
1392
            path = self._mapper.map(prefix)
1398
1393
            vf = self._get_vf(path)
1399
1394
            parent_map = vf.get_parent_map(suffixes)
1400
 
            for key, parents in viewitems(parent_map):
 
1395
            for key, parents in parent_map.items():
1401
1396
                result[prefix + (key,)] = tuple(
1402
1397
                    prefix + (parent,) for parent in parents)
1403
1398
        return result
1449
1444
    def _iter_keys_vf(self, keys):
1450
1445
        prefixes = self._partition_keys(keys)
1451
1446
        sha1s = {}
1452
 
        for prefix, suffixes in viewitems(prefixes):
 
1447
        for prefix, suffixes in prefixes.items():
1453
1448
            path = self._mapper.map(prefix)
1454
1449
            vf = self._get_vf(path)
1455
1450
            yield prefix, suffixes, vf
1459
1454
        sha1s = {}
1460
1455
        for prefix, suffixes, vf in self._iter_keys_vf(keys):
1461
1456
            vf_sha1s = vf.get_sha1s(suffixes)
1462
 
            for suffix, sha1 in viewitems(vf_sha1s):
 
1457
            for suffix, sha1 in vf_sha1s.items():
1463
1458
                sha1s[prefix + (suffix,)] = sha1
1464
1459
        return sha1s
1465
1460
 
1659
1654
        result.update(
1660
1655
            _mod_graph.StackedParentsProvider(
1661
1656
                self._providers).get_parent_map(keys))
1662
 
        for key, parents in viewitems(result):
 
1657
        for key, parents in result.items():
1663
1658
            if parents == ():
1664
1659
                result[key] = (revision.NULL_REVISION,)
1665
1660
        return result
1838
1833
 
1839
1834
    def get_parent_map(self, keys):
1840
1835
        """See VersionedFiles.get_parent_map."""
1841
 
        parent_view = viewitems(self._get_parent_map(k for (k,) in keys))
 
1836
        parent_view = self._get_parent_map(k for (k,) in keys).items()
1842
1837
        return dict(((k,), tuple((p,) for p in v)) for k, v in parent_view)
1843
1838
 
1844
1839
    def get_sha1s(self, keys):
1995
1990
    # gc-optimal ordering is approximately reverse topological,
1996
1991
    # properly grouped by file-id.
1997
1992
    per_prefix_map = {}
1998
 
    for item in viewitems(parent_map):
 
1993
    for item in parent_map.items():
1999
1994
        key = item[0]
2000
1995
        if isinstance(key, bytes) or len(key) == 1:
2001
1996
            prefix = b''
2064
2059
            self._satisfy_refs_for_key(key)
2065
2060
 
2066
2061
    def get_referrers(self):
2067
 
        return set(itertools.chain.from_iterable(viewvalues(self.refs)))
 
2062
        return set(itertools.chain.from_iterable(self.refs.values()))