/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 bzrlib/groupcompress.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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
31
31
    knit,
32
32
    osutils,
33
33
    pack,
 
34
    static_tuple,
34
35
    trace,
35
36
    )
36
37
from bzrlib.btree_index import BTreeBuilder
1630
1631
        keys_to_add = []
1631
1632
        def flush():
1632
1633
            bytes = self._compressor.flush().to_bytes()
 
1634
            self._compressor = GroupCompressor()
1633
1635
            index, start, length = self._access.add_raw_records(
1634
1636
                [(None, len(bytes))], bytes)[0]
1635
1637
            nodes = []
1638
1640
            self._index.add_records(nodes, random_id=random_id)
1639
1641
            self._unadded_refs = {}
1640
1642
            del keys_to_add[:]
1641
 
            self._compressor = GroupCompressor()
1642
1643
 
1643
1644
        last_prefix = None
1644
1645
        max_fulltext_len = 0
1746
1747
                key = record.key
1747
1748
            self._unadded_refs[key] = record.parents
1748
1749
            yield found_sha1
1749
 
            keys_to_add.append((key, '%d %d' % (start_point, end_point),
1750
 
                (record.parents,)))
 
1750
            as_st = static_tuple.StaticTuple.from_sequence
 
1751
            if record.parents is not None:
 
1752
                parents = as_st([as_st(p) for p in record.parents])
 
1753
            else:
 
1754
                parents = None
 
1755
            refs = static_tuple.StaticTuple(parents)
 
1756
            keys_to_add.append((key, '%d %d' % (start_point, end_point), refs))
1751
1757
        if len(keys_to_add):
1752
1758
            flush()
1753
1759
        self._compressor = None
1877
1883
        if not random_id:
1878
1884
            present_nodes = self._get_entries(keys)
1879
1885
            for (index, key, value, node_refs) in present_nodes:
1880
 
                if node_refs != keys[key][1]:
1881
 
                    details = '%s %s %s' % (key, (value, node_refs), keys[key])
 
1886
                # Sometimes these are passed as a list rather than a tuple
 
1887
                node_refs = static_tuple.as_tuples(node_refs)
 
1888
                passed = static_tuple.as_tuples(keys[key])
 
1889
                if node_refs != passed[1]:
 
1890
                    details = '%s %s %s' % (key, (value, node_refs), passed)
1882
1891
                    if self._inconsistency_fatal:
1883
1892
                        raise errors.KnitCorrupt(self, "inconsistent details"
1884
1893
                                                 " in add_records: %s" %