~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/groupcompress_repo.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Repository formats using CHK inventories and groupcompress compression."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import time
20
22
 
21
23
from bzrlib import (
22
 
    bzrdir,
 
24
    controldir,
23
25
    chk_map,
24
26
    chk_serializer,
25
27
    debug,
53
55
    ResumedPack,
54
56
    Packer,
55
57
    )
56
 
from bzrlib.repository import (
 
58
from bzrlib.vf_repository import (
57
59
    StreamSource,
58
60
    )
59
61
from bzrlib.static_tuple import StaticTuple
756
758
            expected_chk_roots)
757
759
        missing_chk_roots = expected_chk_roots.difference(present_chk_roots)
758
760
        if missing_chk_roots:
759
 
            problems.append("missing referenced chk root keys: %s"
 
761
            problems.append(
 
762
                "missing referenced chk root keys: %s."
 
763
                "Run 'bzr reconcile --canonicalize-chks' on the affected "
 
764
                "repository."
760
765
                % (sorted(missing_chk_roots),))
761
766
            # Don't bother checking any further.
762
767
            return problems
952
957
            else:
953
958
                basis_tree = self.revision_tree(basis_revision_id)
954
959
                basis_tree.lock_read()
955
 
                basis_inv = basis_tree.inventory
 
960
                basis_inv = basis_tree.root_inventory
956
961
        try:
957
962
            result = basis_inv.create_by_apply_delta(delta, new_revision_id,
958
963
                propagate_caches=propagate_caches)
978
983
            if record.storage_kind != 'absent':
979
984
                texts[record.key] = record.get_bytes_as('fulltext')
980
985
            else:
981
 
                raise errors.NoSuchRevision(self, record.key)
 
986
                texts[record.key] = None
982
987
        for key in keys:
983
 
            yield inventory.CHKInventory.deserialise(self.chk_bytes, texts[key], key)
 
988
            bytes = texts[key]
 
989
            if bytes is None:
 
990
                yield (None, key[-1])
 
991
            else:
 
992
                yield (inventory.CHKInventory.deserialise(
 
993
                    self.chk_bytes, bytes, key), key[-1])
984
994
 
985
 
    def _iter_inventory_xmls(self, revision_ids, ordering):
 
995
    def _get_inventory_xml(self, revision_id):
 
996
        """Get serialized inventory as a string."""
986
997
        # Without a native 'xml' inventory, this method doesn't make sense.
987
998
        # However older working trees, and older bundles want it - so we supply
988
999
        # it allowing _get_inventory_xml to work. Bundles currently use the
989
1000
        # serializer directly; this also isn't ideal, but there isn't an xml
990
 
        # iteration interface offered at all for repositories. We could make
991
 
        # _iter_inventory_xmls be part of the contract, even if kept private.
992
 
        inv_to_str = self._serializer.write_inventory_to_string
993
 
        for inv in self.iter_inventories(revision_ids, ordering=ordering):
994
 
            yield inv_to_str(inv), inv.revision_id
 
1001
        # iteration interface offered at all for repositories.
 
1002
        return self._serializer.write_inventory_to_string(
 
1003
            self.get_inventory(revision_id))
995
1004
 
996
1005
    def _find_present_inventory_keys(self, revision_keys):
997
1006
        parent_map = self.inventories.get_parent_map(revision_keys)
1261
1270
            yield (stream_info[0],
1262
1271
                wrap_and_count(pb, rc, stream_info[1]))
1263
1272
        self._revision_keys = [(rev_id,) for rev_id in revision_ids]
1264
 
        self.from_repository.revisions.clear_cache()
1265
 
        self.from_repository.signatures.clear_cache()
1266
 
        s = self._get_inventory_stream(self._revision_keys)
1267
 
        yield (s[0], wrap_and_count(pb, rc, s[1]))
1268
 
        self.from_repository.inventories.clear_cache()
1269
1273
        # TODO: The keys to exclude might be part of the search recipe
1270
1274
        # For now, exclude all parents that are at the edge of ancestry, for
1271
1275
        # which we have inventories
1272
1276
        from_repo = self.from_repository
1273
1277
        parent_keys = from_repo._find_parent_keys_of_revisions(
1274
1278
                        self._revision_keys)
 
1279
        self.from_repository.revisions.clear_cache()
 
1280
        self.from_repository.signatures.clear_cache()
 
1281
        # Clear the repo's get_parent_map cache too.
 
1282
        self.from_repository._unstacked_provider.disable_cache()
 
1283
        self.from_repository._unstacked_provider.enable_cache()
 
1284
        s = self._get_inventory_stream(self._revision_keys)
 
1285
        yield (s[0], wrap_and_count(pb, rc, s[1]))
 
1286
        self.from_repository.inventories.clear_cache()
1275
1287
        for stream_info in self._get_filtered_chk_streams(parent_keys):
1276
1288
            yield (stream_info[0], wrap_and_count(pb, rc, stream_info[1]))
1277
1289
        self.from_repository.chk_bytes.clear_cache()
1374
1386
    pack_compresses = True
1375
1387
 
1376
1388
    def _get_matching_bzrdir(self):
1377
 
        return bzrdir.format_registry.make_bzrdir('2a')
 
1389
        return controldir.format_registry.make_bzrdir('2a')
1378
1390
 
1379
1391
    def _ignore_setting_bzrdir(self, format):
1380
1392
        pass
1381
1393
 
1382
1394
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
1383
1395
 
1384
 
    def get_format_string(self):
 
1396
    @classmethod
 
1397
    def get_format_string(cls):
1385
1398
        return ('Bazaar repository format 2a (needs bzr 1.16 or later)\n')
1386
1399
 
1387
1400
    def get_format_description(self):
1396
1409
    """
1397
1410
 
1398
1411
    def _get_matching_bzrdir(self):
1399
 
        return bzrdir.format_registry.make_bzrdir('development-subtree')
 
1412
        return controldir.format_registry.make_bzrdir('development-subtree')
1400
1413
 
1401
1414
    def _ignore_setting_bzrdir(self, format):
1402
1415
        pass
1403
1416
 
1404
1417
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
1405
1418
 
1406
 
    def get_format_string(self):
 
1419
    @classmethod
 
1420
    def get_format_string(cls):
1407
1421
        return ('Bazaar development format 8\n')
1408
1422
 
1409
1423
    def get_format_description(self):