/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

Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        return self.do_repository_request(repository, *args)
42
42
 
43
43
 
 
44
class SmartServerRepositoryGetRevisionGraph(SmartServerRepositoryRequest):
 
45
    
 
46
    def do_repository_request(self, repository, revision_id):
 
47
        """Return the result of repository.get_revision_graph(revision_id).
 
48
        
 
49
        :param repository: The repository to query in.
 
50
        :param revision_id: The utf8 encoded revision_id to get a graph from.
 
51
        :return: A smart server response where the body contains an utf8
 
52
            encoded flattened list of the revision graph.
 
53
        """
 
54
        decoded_revision_id = revision_id.decode('utf8')
 
55
        if not decoded_revision_id:
 
56
            decoded_revision_id = None
 
57
 
 
58
        lines = []
 
59
        try:
 
60
            revision_graph = repository.get_revision_graph(decoded_revision_id)
 
61
        except errors.NoSuchRevision:
 
62
            return SmartServerResponse(('nosuchrevision', revision_id))
 
63
 
 
64
        for revision, parents in revision_graph.items():
 
65
            lines.append(' '.join([revision,] + parents))
 
66
 
 
67
        return SmartServerResponse(('ok', ), '\n'.join(lines).encode('utf8'))
 
68
 
 
69
 
44
70
class SmartServerRequestHasRevision(SmartServerRepositoryRequest):
45
71
 
46
72
    def do_repository_request(self, repository, revision_id):