~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/vf_repository.py

  • Committer: Andrew Bennetts
  • Date: 2011-05-18 15:45:07 UTC
  • mto: This revision was merged to the branch mainline in revision 5895.
  • Revision ID: andrew.bennetts@canonical.com-20110518154507-t3qudgcb7fj3omjc
Use pydoctor in api-docs make target.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib.lazy_import import lazy_import
21
21
lazy_import(globals(), """
22
 
import itertools
23
 
 
24
22
from bzrlib import (
25
23
    check,
26
24
    debug,
78
76
    """Base class for all repository formats that are VersionedFiles-based."""
79
77
 
80
78
    supports_full_versioned_files = True
81
 
    supports_versioned_directories = True
82
79
 
83
80
    # Should commit add an inventory, or an inventory delta to the repository.
84
81
    _commit_inv_deltas = True
279
276
 
280
277
    def _get_delta(self, ie, basis_inv, path):
281
278
        """Get a delta against the basis inventory for ie."""
282
 
        if not basis_inv.has_id(ie.file_id):
 
279
        if ie.file_id not in basis_inv:
283
280
            # add
284
281
            result = (None, path, ie.file_id, ie)
285
282
            self._basis_delta.append(result)
398
395
                # this masks when a change may have occurred against the basis.
399
396
                # To match this we always issue a delta, because the revision
400
397
                # of the root will always be changing.
401
 
                if basis_inv.has_id(ie.file_id):
 
398
                if ie.file_id in basis_inv:
402
399
                    delta = (basis_inv.id2path(ie.file_id), path,
403
400
                        ie.file_id, ie)
404
401
                else:
423
420
        head_set = self._heads(ie.file_id, parent_candiate_entries.keys())
424
421
        heads = []
425
422
        for inv in parent_invs:
426
 
            if inv.has_id(ie.file_id):
 
423
            if ie.file_id in inv:
427
424
                old_rev = inv[ie.file_id].revision
428
425
                if old_rev in head_set:
429
426
                    heads.append(inv[ie.file_id].revision)
1428
1425
            the revision key from each parsed line will be looked up in the
1429
1426
            revision_keys filter.
1430
1427
        :return: a dictionary mapping altered file-ids to an iterable of
1431
 
            revision_ids. Each altered file-ids has the exact revision_ids that
1432
 
            altered it listed explicitly.
 
1428
        revision_ids. Each altered file-ids has the exact revision_ids that
 
1429
        altered it listed explicitly.
1433
1430
        """
1434
1431
        seen = set(self._serializer._find_text_key_references(
1435
1432
                line_iterator).iterkeys())
1464
1461
        :param _inv_weave: The inventory weave from this repository or None.
1465
1462
            If None, the inventory weave will be opened automatically.
1466
1463
        :return: a dictionary mapping altered file-ids to an iterable of
1467
 
            revision_ids. Each altered file-ids has the exact revision_ids that
1468
 
            altered it listed explicitly.
 
1464
        revision_ids. Each altered file-ids has the exact revision_ids that
 
1465
        altered it listed explicitly.
1469
1466
        """
1470
1467
        selected_keys = set((revid,) for revid in revision_ids)
1471
1468
        w = _inv_weave or self.inventories
2555
2552
    @needs_read_lock
2556
2553
    def search_missing_revision_ids(self,
2557
2554
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
2558
 
            find_ghosts=True, revision_ids=None, if_present_ids=None,
2559
 
            limit=None):
 
2555
            find_ghosts=True, revision_ids=None, if_present_ids=None):
2560
2556
        """Return the revision ids that source has that target does not.
2561
2557
 
2562
2558
        :param revision_id: only return revision ids included by this
2586
2582
        # stop searching at found target revisions.
2587
2583
        if not find_ghosts and (revision_ids is not None or if_present_ids is
2588
2584
                not None):
2589
 
            result = self._walk_to_common_revisions(revision_ids,
 
2585
            return self._walk_to_common_revisions(revision_ids,
2590
2586
                    if_present_ids=if_present_ids)
2591
 
            if limit is None:
2592
 
                return result
2593
 
            result_set = result.get_keys()
2594
 
        else:
2595
 
            # generic, possibly worst case, slow code path.
2596
 
            target_ids = set(self.target.all_revision_ids())
2597
 
            source_ids = self._present_source_revisions_for(
2598
 
                revision_ids, if_present_ids)
2599
 
            result_set = set(source_ids).difference(target_ids)
2600
 
        if limit is not None:
2601
 
            topo_ordered = self.source.get_graph().iter_topo_order(result_set)
2602
 
            result_set = set(itertools.islice(topo_ordered, limit))
 
2587
        # generic, possibly worst case, slow code path.
 
2588
        target_ids = set(self.target.all_revision_ids())
 
2589
        source_ids = self._present_source_revisions_for(
 
2590
            revision_ids, if_present_ids)
 
2591
        result_set = set(source_ids).difference(target_ids)
2603
2592
        return self.source.revision_ids_to_search_result(result_set)
2604
2593
 
2605
2594
    def _present_source_revisions_for(self, revision_ids, if_present_ids=None):
3071
3060
        # the parents inserted are not those commit would do - in particular
3072
3061
        # they are not filtered by heads(). RBC, AB
3073
3062
        for revision, tree in parent_trees.iteritems():
3074
 
            if not tree.has_id(ie.file_id):
 
3063
            if ie.file_id not in tree:
3075
3064
                continue
3076
3065
            parent_id = tree.get_file_revision(ie.file_id)
3077
3066
            if parent_id in text_parents: