~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 00:49:50 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909004950-43z4zdicb5u91iet
tweak quick reference naming to make it consistent with other PDFs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
69
69
    lru_cache,
70
70
    pack,
71
71
    progress,
72
 
    static_tuple,
73
72
    trace,
74
73
    tsort,
75
74
    tuned_gzip,
76
 
    ui,
77
75
    )
78
76
""")
79
77
from bzrlib import (
1520
1518
                if source is parent_maps[0]:
1521
1519
                    # this KnitVersionedFiles
1522
1520
                    records = [(key, positions[key][1]) for key in keys]
1523
 
                    for key, raw_data in self._read_records_iter_unchecked(records):
 
1521
                    for key, raw_data, sha1 in self._read_records_iter_raw(records):
1524
1522
                        (record_details, index_memo, _) = positions[key]
1525
1523
                        yield KnitContentFactory(key, global_map[key],
1526
 
                            record_details, None, raw_data, self._factory.annotated, None)
 
1524
                            record_details, sha1, raw_data, self._factory.annotated, None)
1527
1525
                else:
1528
1526
                    vf = self._fallback_vfs[parent_maps.index(source) - 1]
1529
1527
                    for record in vf.get_record_stream(keys, ordering,
1598
1596
        # key = basis_parent, value = index entry to add
1599
1597
        buffered_index_entries = {}
1600
1598
        for record in stream:
1601
 
            kind = record.storage_kind
1602
 
            if kind.startswith('knit-') and kind.endswith('-gz'):
1603
 
                # Check that the ID in the header of the raw knit bytes matches
1604
 
                # the record metadata.
1605
 
                raw_data = record._raw_record
1606
 
                df, rec = self._parse_record_header(record.key, raw_data)
1607
 
                df.close()
1608
1599
            buffered = False
1609
1600
            parents = record.parents
1610
1601
            if record.storage_kind in delta_types:
1712
1703
            # There were index entries buffered at the end of the stream,
1713
1704
            # So these need to be added (if the index supports holding such
1714
1705
            # entries for later insertion)
1715
 
            all_entries = []
1716
1706
            for key in buffered_index_entries:
1717
1707
                index_entries = buffered_index_entries[key]
1718
 
                all_entries.extend(index_entries)
1719
 
            self._index.add_records(
1720
 
                all_entries, missing_compression_parents=True)
 
1708
                self._index.add_records(index_entries,
 
1709
                    missing_compression_parents=True)
1721
1710
 
1722
1711
    def get_missing_compression_parent_keys(self):
1723
1712
        """Return an iterable of keys of missing compression parents.
1756
1745
        :return: An iterator over (line, key).
1757
1746
        """
1758
1747
        if pb is None:
1759
 
            pb = ui.ui_factory.nested_progress_bar()
 
1748
            pb = progress.DummyProgress()
1760
1749
        keys = set(keys)
1761
1750
        total = len(keys)
1762
1751
        done = False
2369
2358
    FLAGS is a comma separated list of flags about the record. Values include
2370
2359
        no-eol, line-delta, fulltext.
2371
2360
    BYTE_OFFSET is the ascii representation of the byte offset in the data file
2372
 
        that the compressed data starts at.
 
2361
        that the the compressed data starts at.
2373
2362
    LENGTH is the ascii representation of the length of the data file.
2374
2363
    PARENT_ID a utf-8 revision id prefixed by a '.' that is a parent of
2375
2364
        REVISION_ID.
2946
2935
        if not random_id:
2947
2936
            present_nodes = self._get_entries(keys)
2948
2937
            for (index, key, value, node_refs) in present_nodes:
2949
 
                parents = node_refs[:1]
2950
 
                # Sometimes these are passed as a list rather than a tuple
2951
 
                passed = static_tuple.as_tuples(keys[key])
2952
 
                passed_parents = passed[1][:1]
2953
2938
                if (value[0] != keys[key][0][0] or
2954
 
                    parents != passed_parents):
2955
 
                    node_refs = static_tuple.as_tuples(node_refs)
 
2939
                    node_refs[:1] != keys[key][1][:1]):
2956
2940
                    raise KnitCorrupt(self, "inconsistent details in add_records"
2957
 
                        ": %s %s" % ((value, node_refs), passed))
 
2941
                        ": %s %s" % ((value, node_refs), keys[key]))
2958
2942
                del keys[key]
2959
2943
        result = []
2960
2944
        if self._parents:
3709
3693
 
3710
3694
try:
3711
3695
    from bzrlib._knit_load_data_pyx import _load_data_c as _load_data
3712
 
except ImportError, e:
3713
 
    osutils.failed_to_load_extension(e)
 
3696
except ImportError:
3714
3697
    from bzrlib._knit_load_data_py import _load_data_py as _load_data