~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/vf_repository.py

  • Committer: Vincent Ladeuil
  • Date: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
from bzrlib.recordcounter import RecordCounter
44
44
from bzrlib.revisiontree import InventoryRevisionTree
45
45
from bzrlib.testament import Testament
 
46
from bzrlib.i18n import gettext
46
47
""")
47
48
 
48
49
from bzrlib import (
70
71
    )
71
72
 
72
73
from bzrlib.trace import (
73
 
    mutter,
 
74
    mutter
74
75
    )
75
76
 
76
77
 
79
80
 
80
81
    supports_full_versioned_files = True
81
82
    supports_versioned_directories = True
 
83
    supports_unreferenced_revisions = True
82
84
 
83
85
    # Should commit add an inventory, or an inventory delta to the repository.
84
86
    _commit_inv_deltas = True
419
421
                return None, False, None
420
422
        # XXX: Friction: parent_candidates should return a list not a dict
421
423
        #      so that we don't have to walk the inventories again.
422
 
        parent_candiate_entries = ie.parent_candidates(parent_invs)
423
 
        head_set = self._heads(ie.file_id, parent_candiate_entries.keys())
 
424
        parent_candidate_entries = ie.parent_candidates(parent_invs)
 
425
        head_set = self._heads(ie.file_id, parent_candidate_entries.keys())
424
426
        heads = []
425
427
        for inv in parent_invs:
426
428
            if inv.has_id(ie.file_id):
441
443
            store = True
442
444
        if not store:
443
445
            # There is a single head, look it up for comparison
444
 
            parent_entry = parent_candiate_entries[heads[0]]
 
446
            parent_entry = parent_candidate_entries[heads[0]]
445
447
            # if the non-content specific data has changed, we'll be writing a
446
448
            # node:
447
449
            if (parent_entry.parent_id != ie.parent_id or
559
561
        :param iter_changes: An iter_changes iterator with the changes to apply
560
562
            to basis_revision_id. The iterator must not include any items with
561
563
            a current kind of None - missing items must be either filtered out
562
 
            or errored-on beefore record_iter_changes sees the item.
 
564
            or errored-on before record_iter_changes sees the item.
563
565
        :param _entry_factory: Private method to bind entry_factory locally for
564
566
            performance.
565
567
        :return: A generator of (file_id, relpath, fs_hash) tuples for use with
1087
1089
        keys = {'chk_bytes':set(), 'inventories':set(), 'texts':set()}
1088
1090
        kinds = ['chk_bytes', 'texts']
1089
1091
        count = len(checker.pending_keys)
1090
 
        bar.update("inventories", 0, 2)
 
1092
        bar.update(gettext("inventories"), 0, 2)
1091
1093
        current_keys = checker.pending_keys
1092
1094
        checker.pending_keys = {}
1093
1095
        # Accumulate current checks.
1113
1115
            del keys['inventories']
1114
1116
        else:
1115
1117
            return
1116
 
        bar.update("texts", 1)
 
1118
        bar.update(gettext("texts"), 1)
1117
1119
        while (checker.pending_keys or keys['chk_bytes']
1118
1120
            or keys['texts']):
1119
1121
            # Something to check.
1182
1184
                'sha1 mismatch: %s has sha1 %s expected %s referenced by %s' %
1183
1185
                (record.key, sha1, item_data[1], item_data[2]))
1184
1186
 
 
1187
    @needs_read_lock
 
1188
    def _eliminate_revisions_not_present(self, revision_ids):
 
1189
        """Check every revision id in revision_ids to see if we have it.
 
1190
 
 
1191
        Returns a set of the present revisions.
 
1192
        """
 
1193
        result = []
 
1194
        graph = self.get_graph()
 
1195
        parent_map = graph.get_parent_map(revision_ids)
 
1196
        # The old API returned a list, should this actually be a set?
 
1197
        return parent_map.keys()
 
1198
 
1185
1199
    def __init__(self, _format, a_bzrdir, control_files):
1186
1200
        """Instantiate a VersionedFileRepository.
1187
1201
 
1188
1202
        :param _format: The format of the repository on disk.
1189
 
        :param a_bzrdir: The BzrDir of the repository.
 
1203
        :param controldir: The ControlDir of the repository.
1190
1204
        :param control_files: Control files to use for locking, etc.
1191
1205
        """
1192
1206
        # In the future we will have a single api for all stores for
1194
1208
        # this construct will accept instances of those things.
1195
1209
        super(VersionedFileRepository, self).__init__(_format, a_bzrdir,
1196
1210
            control_files)
 
1211
        self._transport = control_files._transport
 
1212
        self.base = self._transport.base
1197
1213
        # for tests
1198
1214
        self._reconcile_does_inventory_gc = True
1199
1215
        self._reconcile_fixes_text_parents = False
1556
1572
        batch_size = 10 # should be ~150MB on a 55K path tree
1557
1573
        batch_count = len(revision_order) / batch_size + 1
1558
1574
        processed_texts = 0
1559
 
        pb.update("Calculating text parents", processed_texts, text_count)
 
1575
        pb.update(gettext("Calculating text parents"), processed_texts, text_count)
1560
1576
        for offset in xrange(batch_count):
1561
1577
            to_query = revision_order[offset * batch_size:(offset + 1) *
1562
1578
                batch_size]
1565
1581
            for revision_id in to_query:
1566
1582
                parent_ids = ancestors[revision_id]
1567
1583
                for text_key in revision_keys[revision_id]:
1568
 
                    pb.update("Calculating text parents", processed_texts)
 
1584
                    pb.update(gettext("Calculating text parents"), processed_texts)
1569
1585
                    processed_texts += 1
1570
1586
                    candidate_parents = []
1571
1587
                    for parent_id in parent_ids:
1641
1657
        num_file_ids = len(file_ids)
1642
1658
        for file_id, altered_versions in file_ids.iteritems():
1643
1659
            if pb is not None:
1644
 
                pb.update("Fetch texts", count, num_file_ids)
 
1660
                pb.update(gettext("Fetch texts"), count, num_file_ids)
1645
1661
            count += 1
1646
1662
            yield ("file", file_id, altered_versions)
1647
1663
 
2452
2468
            self.text_index.iterkeys()])
2453
2469
        # text keys is now grouped by file_id
2454
2470
        n_versions = len(self.text_index)
2455
 
        progress_bar.update('loading text store', 0, n_versions)
 
2471
        progress_bar.update(gettext('loading text store'), 0, n_versions)
2456
2472
        parent_map = self.repository.texts.get_parent_map(self.text_index)
2457
2473
        # On unlistable transports this could well be empty/error...
2458
2474
        text_keys = self.repository.texts.keys()
2459
2475
        unused_keys = frozenset(text_keys) - set(self.text_index)
2460
2476
        for num, key in enumerate(self.text_index.iterkeys()):
2461
 
            progress_bar.update('checking text graph', num, n_versions)
 
2477
            progress_bar.update(gettext('checking text graph'), num, n_versions)
2462
2478
            correct_parents = self.calculate_file_version_parents(key)
2463
2479
            try:
2464
2480
                knit_parents = parent_map[key]
2485
2501
                            content is copied.
2486
2502
        :return: None.
2487
2503
        """
2488
 
        ui.ui_factory.warn_experimental_format_fetch(self)
 
2504
        if self.target._format.experimental:
 
2505
            ui.ui_factory.show_user_warning('experimental_format_fetch',
 
2506
                from_format=self.source._format,
 
2507
                to_format=self.target._format)
2489
2508
        from bzrlib.fetch import RepoFetcher
2490
2509
        # See <https://launchpad.net/bugs/456077> asking for a warning here
2491
2510
        if self.source._format.network_name() != self.target._format.network_name():
2905
2924
        for offset in range(0, len(revision_ids), batch_size):
2906
2925
            self.target.start_write_group()
2907
2926
            try:
2908
 
                pb.update('Transferring revisions', offset,
 
2927
                pb.update(gettext('Transferring revisions'), offset,
2909
2928
                          len(revision_ids))
2910
2929
                batch = revision_ids[offset:offset+batch_size]
2911
2930
                basis_id = self._fetch_batch(batch, basis_id, cache)
2919
2938
                    hints.extend(hint)
2920
2939
        if hints and self.target._format.pack_compresses:
2921
2940
            self.target.pack(hint=hints)
2922
 
        pb.update('Transferring revisions', len(revision_ids),
 
2941
        pb.update(gettext('Transferring revisions'), len(revision_ids),
2923
2942
                  len(revision_ids))
2924
2943
 
2925
2944
    @needs_write_lock
2930
2949
            revision_ids = fetch_spec.get_keys()
2931
2950
        else:
2932
2951
            revision_ids = None
2933
 
        ui.ui_factory.warn_experimental_format_fetch(self)
 
2952
        if self.source._format.experimental:
 
2953
            ui.ui_factory.show_user_warning('experimental_format_fetch',
 
2954
                from_format=self.source._format,
 
2955
                to_format=self.target._format)
2934
2956
        if (not self.source.supports_rich_root()
2935
2957
            and self.target.supports_rich_root()):
2936
2958
            self._converting_to_rich_root = True
3031
3053
            _install_revision(repository, revision, revision_tree, signature,
3032
3054
                inventory_cache)
3033
3055
            if pb is not None:
3034
 
                pb.update('Transferring revisions', n + 1, num_revisions)
 
3056
                pb.update(gettext('Transferring revisions'), n + 1, num_revisions)
3035
3057
    except:
3036
3058
        repository.abort_write_group()
3037
3059
        raise