~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: Robert Collins
  • Date: 2007-06-26 08:52:20 UTC
  • mto: This revision was merged to the branch mainline in revision 2554.
  • Revision ID: robertc@robertcollins.net-20070626085220-iovhwfjflk8vffbh
Add require_api API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib import (
18
18
    bzrdir,
 
19
    deprecated_graph,
19
20
    errors,
20
 
    graph,
21
21
    knit,
22
22
    lockable_files,
23
23
    lockdir,
39
39
from bzrlib.trace import mutter, note, warning
40
40
 
41
41
 
 
42
class _KnitParentsProvider(object):
 
43
 
 
44
    def __init__(self, knit):
 
45
        self._knit = knit
 
46
 
 
47
    def __repr__(self):
 
48
        return 'KnitParentsProvider(%r)' % self._knit
 
49
 
 
50
    def get_parents(self, revision_ids):
 
51
        parents_list = []
 
52
        for revision_id in revision_ids:
 
53
            if revision_id == _mod_revision.NULL_REVISION:
 
54
                parents = []
 
55
            else:
 
56
                try:
 
57
                    parents = self._knit.get_parents_with_ghosts(revision_id)
 
58
                except errors.RevisionNotPresent:
 
59
                    parents = None
 
60
                else:
 
61
                    if len(parents) == 0:
 
62
                        parents = [_mod_revision.NULL_REVISION]
 
63
            parents_list.append(parents)
 
64
        return parents_list
 
65
 
 
66
 
42
67
class KnitRepository(MetaDirRepository):
43
68
    """Knit format repository."""
44
69
 
86
111
        return self._fileid_involved_by_set(changed)
87
112
 
88
113
    @needs_read_lock
89
 
    def get_ancestry(self, revision_id):
 
114
    def get_ancestry(self, revision_id, topo_sorted=True):
90
115
        """Return a list of revision-ids integrated by a revision.
91
116
        
92
 
        This is topologically sorted.
 
117
        This is topologically sorted, unless 'topo_sorted' is specified as
 
118
        False.
93
119
        """
94
120
        if revision_id is None:
95
121
            return [None]
96
122
        revision_id = osutils.safe_revision_id(revision_id)
97
123
        vf = self._get_revision_vf()
98
124
        try:
99
 
            return [None] + vf.get_ancestry(revision_id)
 
125
            return [None] + vf.get_ancestry(revision_id, topo_sorted)
100
126
        except errors.RevisionNotPresent:
101
127
            raise errors.NoSuchRevision(self, revision_id)
102
128
 
144
170
        :param revision_ids: an iterable of revisions to graph or None for all.
145
171
        :return: a Graph object with the graph reachable from revision_ids.
146
172
        """
147
 
        result = graph.Graph()
 
173
        result = deprecated_graph.Graph()
148
174
        vf = self._get_revision_vf()
149
175
        versions = set(vf.versions())
150
176
        if not revision_ids:
202
228
        revision_id = osutils.safe_revision_id(revision_id)
203
229
        return self._get_revision_vf().get_parents(revision_id)
204
230
 
 
231
    def _make_parents_provider(self):
 
232
        return _KnitParentsProvider(self._get_revision_vf())
 
233
 
205
234
 
206
235
class KnitRepository3(KnitRepository):
207
236