/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/smart/repository.py

  • Committer: Robert Collins
  • Date: 2008-03-26 21:42:35 UTC
  • mto: This revision was merged to the branch mainline in revision 3313.
  • Revision ID: robertc@robertcollins.net-20080326214235-3wmnqamcgytwif89
 * ``VersionedFile.get_graph`` is deprecated, with no replacement method.
   The method was size(history) and not desirable. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
            repository.unlock()
88
88
 
89
89
 
 
90
class SmartServerRepositoryReadLocked(SmartServerRepositoryRequest):
 
91
    """Calls self.do_readlocked_repository_request."""
 
92
 
 
93
    def do_repository_request(self, repository, *args):
 
94
        """Read lock a repository for do_readlocked_repository_request."""
 
95
        repository.lock_read()
 
96
        try:
 
97
            return self.do_readlocked_repository_request(repository, *args)
 
98
        finally:
 
99
            repository.unlock()
 
100
 
 
101
 
90
102
class SmartServerRepositoryGetParentMap(SmartServerRepositoryRequest):
91
103
    """Bzr 1.2+ - get parent data for revisions during a graph search."""
92
104
    
173
185
            ('ok', ), bz2.compress('\n'.join(lines)))
174
186
 
175
187
 
176
 
class SmartServerRepositoryGetRevisionGraph(SmartServerRepositoryRequest):
 
188
class SmartServerRepositoryGetRevisionGraph(SmartServerRepositoryReadLocked):
177
189
    
178
 
    def do_repository_request(self, repository, revision_id):
 
190
    def do_readlocked_repository_request(self, repository, revision_id):
179
191
        """Return the result of repository.get_revision_graph(revision_id).
 
192
 
 
193
        Deprecated as of bzr 1.4, but supported for older clients.
180
194
        
181
195
        :param repository: The repository to query in.
182
196
        :param revision_id: The utf8 encoded revision_id to get a graph from.
187
201
            revision_id = None
188
202
 
189
203
        lines = []
190
 
        try:
191
 
            revision_graph = repository.get_revision_graph(revision_id)
192
 
        except errors.NoSuchRevision:
 
204
        graph = repository.get_graph()
 
205
        if revision_id:
 
206
            search_ids = [revision_id]
 
207
        else:
 
208
            search_ids = repository.all_revision_ids()
 
209
        search = graph._make_breadth_first_searcher(search_ids)
 
210
        transitive_ids = set()
 
211
        map(transitive_ids.update, list(search))
 
212
        parent_map = graph.get_parent_map(transitive_ids)
 
213
        revision_graph = {}
 
214
        if _mod_revision.NULL_REVISION in parent_map:
 
215
            del parent_map[_mod_revision.NULL_REVISION]
 
216
        for key, parents in parent_map.iteritems():
 
217
            revision_graph[key] = tuple(parent for parent in parents if
 
218
                parent in parent_map)
 
219
        if revision_id and revision_id not in revision_graph:
193
220
            # Note that we return an empty body, rather than omitting the body.
194
221
            # This way the client knows that it can always expect to find a body
195
222
            # in the response for this method, even in the error case.