~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

Add SmartServerBranchRequestLastRevisionInfo method.
(Wouter van Heyst, Robert Collins, Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib import errors
21
21
from bzrlib.bzrdir import BzrDir
 
22
from bzrlib.revision import NULL_REVISION
22
23
from bzrlib.smart.request import SmartServerRequest, SmartServerResponse
23
24
 
24
25
 
48
49
        """
49
50
        return SmartServerResponse(('ok', ),
50
51
            ('\x00'.join(branch.revision_history())).encode('utf8'))
 
52
 
 
53
 
 
54
class SmartServerBranchRequestLastRevisionInfo(SmartServerBranchRequest):
 
55
    
 
56
    def do_with_branch(self, branch):
 
57
        """Return branch.last_revision_info().
 
58
        
 
59
        The revno is encoded in decimal, the revision_id is encoded as utf8.
 
60
        """
 
61
        revno, last_revision = branch.last_revision_info()
 
62
        if last_revision == NULL_REVISION:
 
63
            last_revision = ''
 
64
        return SmartServerResponse(
 
65
            ('ok', str(revno), last_revision.encode('utf8')))
 
66
 
 
67