/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/knit.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:
54
54
from __future__ import absolute_import
55
55
 
56
56
import operator
 
57
from io import BytesIO
57
58
import os
58
59
 
59
60
from ..lazy_import import lazy_import
95
96
    sha_strings,
96
97
    split_lines,
97
98
    )
98
 
from ..sixish import (
99
 
    BytesIO,
100
 
    range,
101
 
    viewitems,
102
 
    viewvalues,
103
 
    )
104
99
from ..bzr.versionedfile import (
105
100
    _KeyRefs,
106
101
    AbsentContentFactory,
954
949
                next_keys.add(compression_parent)
955
950
        build_keys = next_keys
956
951
    return sum(index_memo[2]
957
 
               for index_memo in viewvalues(all_build_index_memos))
 
952
               for index_memo in all_build_index_memos.values())
958
953
 
959
954
 
960
955
class KnitVersionedFiles(VersionedFilesWithFallbacks):
1287
1282
            build_details = self._index.get_build_details(pending_components)
1288
1283
            current_components = set(pending_components)
1289
1284
            pending_components = set()
1290
 
            for key, details in viewitems(build_details):
 
1285
            for key, details in build_details.items():
1291
1286
                (index_memo, compression_parent, parents,
1292
1287
                 record_details) = details
1293
1288
                if compression_parent is not None:
1394
1389
                # key = component_id, r = record_details, i_m = index_memo,
1395
1390
                # n = next
1396
1391
                records = [(key, i_m) for key, (r, i_m, n)
1397
 
                           in viewitems(position_map)]
 
1392
                           in position_map.items()]
1398
1393
                # Sort by the index memo, so that we request records from the
1399
1394
                # same pack file together, and in forward-sorted order
1400
1395
                records.sort(key=operator.itemgetter(1))
1526
1521
            # map from key to
1527
1522
            # (record_details, access_memo, compression_parent_key)
1528
1523
            positions = dict((key, self._build_details_to_components(details))
1529
 
                             for key, details in viewitems(build_details))
 
1524
                             for key, details in build_details.items())
1530
1525
        absent_keys = keys.difference(set(positions))
1531
1526
        # There may be more absent keys : if we're missing the basis component
1532
1527
        # and are trying to include the delta closure.
1641
1636
        missing = set(keys)
1642
1637
        record_map = self._get_record_map(missing, allow_missing=True)
1643
1638
        result = {}
1644
 
        for key, details in viewitems(record_map):
 
1639
        for key, details in record_map.items():
1645
1640
            if key not in missing:
1646
1641
                continue
1647
1642
            # record entry 2 is the 'digest'.
1871
1866
                # we need key, position, length
1872
1867
                key_records = []
1873
1868
                build_details = self._index.get_build_details(keys)
1874
 
                for key, details in viewitems(build_details):
 
1869
                for key, details in build_details.items():
1875
1870
                    if key in keys:
1876
1871
                        key_records.append((key, details[0]))
1877
1872
                records_iter = enumerate(self._read_records_iter(key_records))
2281
2276
        # one line with next ('' for None)
2282
2277
        # one line with byte count of the record bytes
2283
2278
        # the record bytes
2284
 
        for key, (record_bytes, (method, noeol), next) in viewitems(
2285
 
                self._raw_record_map):
 
2279
        for key, (record_bytes, (method, noeol), next) in (
 
2280
                self._raw_record_map.items()):
2286
2281
            key_bytes = b'\x00'.join(key)
2287
2282
            parents = self.global_map.get(key, None)
2288
2283
            if parents is None:
3012
3007
                del keys[key]
3013
3008
        result = []
3014
3009
        if self._parents:
3015
 
            for key, (value, node_refs) in viewitems(keys):
 
3010
            for key, (value, node_refs) in keys.items():
3016
3011
                result.append((key, value, node_refs))
3017
3012
        else:
3018
 
            for key, (value, node_refs) in viewitems(keys):
 
3013
            for key, (value, node_refs) in keys.items():
3019
3014
                result.append((key, value))
3020
3015
        self._add_callback(result)
3021
3016
        if missing_compression_parents:
3406
3401
            self._all_build_details.update(build_details)
3407
3402
            # new_nodes = self._vf._index._get_entries(this_iteration)
3408
3403
            pending = set()
3409
 
            for key, details in viewitems(build_details):
 
3404
            for key, details in build_details.items():
3410
3405
                (index_memo, compression_parent, parent_keys,
3411
3406
                 record_details) = details
3412
3407
                self._parent_map[key] = parent_keys