~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Andrew Bennetts
  • Date: 2009-09-01 06:32:42 UTC
  • mto: (4634.6.23 2.0)
  • mto: This revision was merged to the branch mainline in revision 4676.
  • Revision ID: andrew.bennetts@canonical.com-20090901063242-96on706kiblvtnsf
Put new key tracking in _KeyRefs rather than alongside it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1731
1731
        self._is_locked = is_locked
1732
1732
        self._inconsistency_fatal = inconsistency_fatal
1733
1733
        if track_external_parent_refs:
1734
 
            self._key_dependencies = knit._KeyRefs()
 
1734
            self._key_dependencies = knit._KeyRefs(
 
1735
                track_new_keys=track_new_keys)
1735
1736
        else:
1736
1737
            self._key_dependencies = None
1737
 
        if track_new_keys:
1738
 
            self._new_keys = set()
1739
 
        else:
1740
 
            self._new_keys = None
1741
1738
 
1742
1739
    def add_records(self, records, random_id=False):
1743
1740
        """Add multiple records to the index.
1795
1792
                    result.append((key, value))
1796
1793
            records = result
1797
1794
        key_dependencies = self._key_dependencies
1798
 
        if key_dependencies is not None and self._parents:
1799
 
            for key, value, refs in records:
1800
 
                parents = refs[0]
1801
 
                key_dependencies.add_references(key, parents)
1802
 
        new_keys = self._new_keys
1803
 
        if new_keys is not None:
1804
 
            for key, value, refs in records:
1805
 
                new_keys.add(key)
 
1795
        if key_dependencies is not None:
 
1796
            if self._parents:
 
1797
                for key, value, refs in records:
 
1798
                    parents = refs[0]
 
1799
                    key_dependencies.add_references(key, parents)
 
1800
            else:
 
1801
                for key, value, refs in records:
 
1802
                    new_keys.add_key(key)
1806
1803
        self._add_callback(records)
1807
1804
 
1808
1805
    def _check_read(self):
1861
1858
        """Return the keys of missing parents."""
1862
1859
        # Copied from _KnitGraphIndex.get_missing_parents
1863
1860
        # We may have false positives, so filter those out.
1864
 
        self._key_dependencies.add_keys(
 
1861
        self._key_dependencies.satisfy_refs_for_keys(
1865
1862
            self.get_parent_map(self._key_dependencies.get_unsatisfied_refs()))
1866
1863
        return frozenset(self._key_dependencies.get_unsatisfied_refs())
1867
1864
 
1926
1923
        :param graph_index: A GraphIndex
1927
1924
        """
1928
1925
        key_dependencies = self._key_dependencies
1929
 
        new_keys = self._new_keys
1930
 
        if key_dependencies is None and new_keys is None:
 
1926
        if key_dependencies is None:
1931
1927
            return
1932
1928
        for node in graph_index.iter_all_entries():
1933
 
            if key_dependencies is not None:
1934
 
                # Add parent refs from graph_index (and discard parent refs
1935
 
                # that the graph_index has).
1936
 
                key_dependencies.add_references(node[1], node[3][0])
1937
 
            if new_keys is not None:
1938
 
                new_keys.add(node[1])
 
1929
            # Add parent refs from graph_index (and discard parent refs
 
1930
            # that the graph_index has).
 
1931
            key_dependencies.add_references(node[1], node[3][0])
1939
1932
 
1940
1933
 
1941
1934
from bzrlib._groupcompress_py import (