/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: Canonical.com Patch Queue Manager
  • Date: 2008-03-28 06:42:20 UTC
  • mfrom: (3287.6.9 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080328064220-ongijg78bfqhvbay
Deprecate a number of VersionedFile method calls,
        and Repository.get_revision_graph. (Robert Collins)

Show diffs side-by-side

added added

removed removed

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