~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/vf_repository.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

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
47
46
""")
48
47
 
49
48
from bzrlib import (
71
70
    )
72
71
 
73
72
from bzrlib.trace import (
74
 
    mutter
 
73
    mutter,
75
74
    )
76
75
 
77
76
 
79
78
    """Base class for all repository formats that are VersionedFiles-based."""
80
79
 
81
80
    supports_full_versioned_files = True
82
 
    supports_versioned_directories = True
83
81
 
84
82
    # Should commit add an inventory, or an inventory delta to the repository.
85
83
    _commit_inv_deltas = True
280
278
 
281
279
    def _get_delta(self, ie, basis_inv, path):
282
280
        """Get a delta against the basis inventory for ie."""
283
 
        if not basis_inv.has_id(ie.file_id):
 
281
        if ie.file_id not in basis_inv:
284
282
            # add
285
283
            result = (None, path, ie.file_id, ie)
286
284
            self._basis_delta.append(result)
399
397
                # this masks when a change may have occurred against the basis.
400
398
                # To match this we always issue a delta, because the revision
401
399
                # of the root will always be changing.
402
 
                if basis_inv.has_id(ie.file_id):
 
400
                if ie.file_id in basis_inv:
403
401
                    delta = (basis_inv.id2path(ie.file_id), path,
404
402
                        ie.file_id, ie)
405
403
                else:
420
418
                return None, False, None
421
419
        # XXX: Friction: parent_candidates should return a list not a dict
422
420
        #      so that we don't have to walk the inventories again.
423
 
        parent_candidate_entries = ie.parent_candidates(parent_invs)
424
 
        head_set = self._heads(ie.file_id, parent_candidate_entries.keys())
 
421
        parent_candiate_entries = ie.parent_candidates(parent_invs)
 
422
        head_set = self._heads(ie.file_id, parent_candiate_entries.keys())
425
423
        heads = []
426
424
        for inv in parent_invs:
427
 
            if inv.has_id(ie.file_id):
 
425
            if ie.file_id in inv:
428
426
                old_rev = inv[ie.file_id].revision
429
427
                if old_rev in head_set:
430
428
                    heads.append(inv[ie.file_id].revision)
442
440
            store = True
443
441
        if not store:
444
442
            # There is a single head, look it up for comparison
445
 
            parent_entry = parent_candidate_entries[heads[0]]
 
443
            parent_entry = parent_candiate_entries[heads[0]]
446
444
            # if the non-content specific data has changed, we'll be writing a
447
445
            # node:
448
446
            if (parent_entry.parent_id != ie.parent_id or
560
558
        :param iter_changes: An iter_changes iterator with the changes to apply
561
559
            to basis_revision_id. The iterator must not include any items with
562
560
            a current kind of None - missing items must be either filtered out
563
 
            or errored-on before record_iter_changes sees the item.
 
561
            or errored-on beefore record_iter_changes sees the item.
564
562
        :param _entry_factory: Private method to bind entry_factory locally for
565
563
            performance.
566
564
        :return: A generator of (file_id, relpath, fs_hash) tuples for use with
919
917
        """
920
918
        if not self._format.supports_external_lookups:
921
919
            raise errors.UnstackableRepositoryFormat(self._format, self.base)
922
 
        # This can raise an exception, so should be done before we lock the
923
 
        # fallback repository.
924
 
        self._check_fallback_repository(repository)
925
920
        if self.is_locked():
926
921
            # This repository will call fallback.unlock() when we transition to
927
922
            # the unlocked state, so we make sure to increment the lock count
928
923
            repository.lock_read()
 
924
        self._check_fallback_repository(repository)
929
925
        self._fallback_repositories.append(repository)
930
926
        self.texts.add_fallback_versioned_files(repository.texts)
931
927
        self.inventories.add_fallback_versioned_files(repository.inventories)
1088
1084
        keys = {'chk_bytes':set(), 'inventories':set(), 'texts':set()}
1089
1085
        kinds = ['chk_bytes', 'texts']
1090
1086
        count = len(checker.pending_keys)
1091
 
        bar.update(gettext("inventories"), 0, 2)
 
1087
        bar.update("inventories", 0, 2)
1092
1088
        current_keys = checker.pending_keys
1093
1089
        checker.pending_keys = {}
1094
1090
        # Accumulate current checks.
1114
1110
            del keys['inventories']
1115
1111
        else:
1116
1112
            return
1117
 
        bar.update(gettext("texts"), 1)
 
1113
        bar.update("texts", 1)
1118
1114
        while (checker.pending_keys or keys['chk_bytes']
1119
1115
            or keys['texts']):
1120
1116
            # Something to check.
1183
1179
                'sha1 mismatch: %s has sha1 %s expected %s referenced by %s' %
1184
1180
                (record.key, sha1, item_data[1], item_data[2]))
1185
1181
 
1186
 
    @needs_read_lock
1187
 
    def _eliminate_revisions_not_present(self, revision_ids):
1188
 
        """Check every revision id in revision_ids to see if we have it.
1189
 
 
1190
 
        Returns a set of the present revisions.
1191
 
        """
1192
 
        result = []
1193
 
        graph = self.get_graph()
1194
 
        parent_map = graph.get_parent_map(revision_ids)
1195
 
        # The old API returned a list, should this actually be a set?
1196
 
        return parent_map.keys()
1197
 
 
1198
1182
    def __init__(self, _format, a_bzrdir, control_files):
1199
1183
        """Instantiate a VersionedFileRepository.
1200
1184
 
1207
1191
        # this construct will accept instances of those things.
1208
1192
        super(VersionedFileRepository, self).__init__(_format, a_bzrdir,
1209
1193
            control_files)
1210
 
        self._transport = control_files._transport
1211
 
        self.base = self._transport.base
1212
1194
        # for tests
1213
1195
        self._reconcile_does_inventory_gc = True
1214
1196
        self._reconcile_fixes_text_parents = False
1571
1553
        batch_size = 10 # should be ~150MB on a 55K path tree
1572
1554
        batch_count = len(revision_order) / batch_size + 1
1573
1555
        processed_texts = 0
1574
 
        pb.update(gettext("Calculating text parents"), processed_texts, text_count)
 
1556
        pb.update("Calculating text parents", processed_texts, text_count)
1575
1557
        for offset in xrange(batch_count):
1576
1558
            to_query = revision_order[offset * batch_size:(offset + 1) *
1577
1559
                batch_size]
1580
1562
            for revision_id in to_query:
1581
1563
                parent_ids = ancestors[revision_id]
1582
1564
                for text_key in revision_keys[revision_id]:
1583
 
                    pb.update(gettext("Calculating text parents"), processed_texts)
 
1565
                    pb.update("Calculating text parents", processed_texts)
1584
1566
                    processed_texts += 1
1585
1567
                    candidate_parents = []
1586
1568
                    for parent_id in parent_ids:
1656
1638
        num_file_ids = len(file_ids)
1657
1639
        for file_id, altered_versions in file_ids.iteritems():
1658
1640
            if pb is not None:
1659
 
                pb.update(gettext("Fetch texts"), count, num_file_ids)
 
1641
                pb.update("Fetch texts", count, num_file_ids)
1660
1642
            count += 1
1661
1643
            yield ("file", file_id, altered_versions)
1662
1644
 
2467
2449
            self.text_index.iterkeys()])
2468
2450
        # text keys is now grouped by file_id
2469
2451
        n_versions = len(self.text_index)
2470
 
        progress_bar.update(gettext('loading text store'), 0, n_versions)
 
2452
        progress_bar.update('loading text store', 0, n_versions)
2471
2453
        parent_map = self.repository.texts.get_parent_map(self.text_index)
2472
2454
        # On unlistable transports this could well be empty/error...
2473
2455
        text_keys = self.repository.texts.keys()
2474
2456
        unused_keys = frozenset(text_keys) - set(self.text_index)
2475
2457
        for num, key in enumerate(self.text_index.iterkeys()):
2476
 
            progress_bar.update(gettext('checking text graph'), num, n_versions)
 
2458
            progress_bar.update('checking text graph', num, n_versions)
2477
2459
            correct_parents = self.calculate_file_version_parents(key)
2478
2460
            try:
2479
2461
                knit_parents = parent_map[key]
2500
2482
                            content is copied.
2501
2483
        :return: None.
2502
2484
        """
2503
 
        if self.target._format.experimental:
2504
 
            ui.ui_factory.show_user_warning('experimental_format_fetch',
2505
 
                from_format=self.source._format,
2506
 
                to_format=self.target._format)
 
2485
        ui.ui_factory.warn_experimental_format_fetch(self)
2507
2486
        from bzrlib.fetch import RepoFetcher
2508
2487
        # See <https://launchpad.net/bugs/456077> asking for a warning here
2509
2488
        if self.source._format.network_name() != self.target._format.network_name():
2923
2902
        for offset in range(0, len(revision_ids), batch_size):
2924
2903
            self.target.start_write_group()
2925
2904
            try:
2926
 
                pb.update(gettext('Transferring revisions'), offset,
 
2905
                pb.update('Transferring revisions', offset,
2927
2906
                          len(revision_ids))
2928
2907
                batch = revision_ids[offset:offset+batch_size]
2929
2908
                basis_id = self._fetch_batch(batch, basis_id, cache)
2937
2916
                    hints.extend(hint)
2938
2917
        if hints and self.target._format.pack_compresses:
2939
2918
            self.target.pack(hint=hints)
2940
 
        pb.update(gettext('Transferring revisions'), len(revision_ids),
 
2919
        pb.update('Transferring revisions', len(revision_ids),
2941
2920
                  len(revision_ids))
2942
2921
 
2943
2922
    @needs_write_lock
2948
2927
            revision_ids = fetch_spec.get_keys()
2949
2928
        else:
2950
2929
            revision_ids = None
2951
 
        if self.source._format.experimental:
2952
 
            ui.ui_factory.show_user_warning('experimental_format_fetch',
2953
 
                from_format=self.source._format,
2954
 
                to_format=self.target._format)
 
2930
        ui.ui_factory.warn_experimental_format_fetch(self)
2955
2931
        if (not self.source.supports_rich_root()
2956
2932
            and self.target.supports_rich_root()):
2957
2933
            self._converting_to_rich_root = True
3052
3028
            _install_revision(repository, revision, revision_tree, signature,
3053
3029
                inventory_cache)
3054
3030
            if pb is not None:
3055
 
                pb.update(gettext('Transferring revisions'), n + 1, num_revisions)
 
3031
                pb.update('Transferring revisions', n + 1, num_revisions)
3056
3032
    except:
3057
3033
        repository.abort_write_group()
3058
3034
        raise
3094
3070
        # the parents inserted are not those commit would do - in particular
3095
3071
        # they are not filtered by heads(). RBC, AB
3096
3072
        for revision, tree in parent_trees.iteritems():
3097
 
            if not tree.has_id(ie.file_id):
 
3073
            if ie.file_id not in tree:
3098
3074
                continue
3099
3075
            parent_id = tree.get_file_revision(ie.file_id)
3100
3076
            if parent_id in text_parents: