~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
 
29
29
class SmartServerBranchRequest(SmartServerRequest):
30
 
    """Base class for handling common branch request logic."""
 
30
    """Base class for handling common branch request logic.
 
31
    """
31
32
 
32
33
    def do(self, path, *args):
33
34
        """Execute a request for a branch at path.
 
35
    
 
36
        All Branch requests take a path to the branch as their first argument.
34
37
 
35
38
        If the branch is a branch reference, NotBranchError is raised.
 
39
 
 
40
        :param path: The path for the repository as received from the
 
41
            client.
 
42
        :return: A SmartServerResponse from self.do_with_branch().
36
43
        """
37
 
        transport = self._backing_transport.clone(path)
 
44
        transport = self.transport_from_client_path(path)
38
45
        bzrdir = BzrDir.open_from_transport(transport)
39
46
        if bzrdir.get_branch_reference() is not None:
40
47
            raise errors.NotBranchError(transport.base)
116
123
        return SuccessfulSmartServerResponse(('ok',))
117
124
 
118
125
 
 
126
class SmartServerBranchRequestSetLastRevisionInfo(
 
127
    SmartServerLockedBranchRequest):
 
128
    """Branch.set_last_revision_info.  Sets the revno and the revision ID of
 
129
    the specified branch.
 
130
 
 
131
    New in bzrlib 1.4.
 
132
    """
 
133
    
 
134
    def do_with_locked_branch(self, branch, new_revno, new_last_revision_id):
 
135
        try:
 
136
            branch.set_last_revision_info(int(new_revno), new_last_revision_id)
 
137
        except errors.NoSuchRevision:
 
138
            return FailedSmartServerResponse(
 
139
                ('NoSuchRevision', new_last_revision_id))
 
140
        return SuccessfulSmartServerResponse(('ok',))
 
141
 
 
142
 
119
143
class SmartServerBranchRequestLockWrite(SmartServerBranchRequest):
120
144
    
121
145
    def do_with_branch(self, branch, branch_token='', repo_token=''):