~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

  • Committer: John Arbash Meinel
  • Date: 2007-05-04 18:59:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070504185936-1mjdoqmtz74xe5mg
A C implementation of _fields_to_entry_0_parents drops the time from 400ms to 330ms for a 21k-entry tree

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.
31
 
    """
 
30
    """Base class for handling common branch request logic."""
32
31
 
33
32
    def do(self, path, *args):
34
33
        """Execute a request for a branch at path.
35
 
    
36
 
        All Branch requests take a path to the branch as their first argument.
37
34
 
38
35
        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().
43
36
        """
44
 
        transport = self.transport_from_client_path(path)
 
37
        transport = self._backing_transport.clone(path)
45
38
        bzrdir = BzrDir.open_from_transport(transport)
46
39
        if bzrdir.get_branch_reference() is not None:
47
40
            raise errors.NotBranchError(transport.base)
135
128
            try:
136
129
                branch_token = branch.lock_write(token=branch_token)
137
130
            finally:
138
 
                # this leaves the repository with 1 lock
139
131
                branch.repository.unlock()
140
132
        except errors.LockContention:
141
133
            return FailedSmartServerResponse(('LockContention',))
143
135
            return FailedSmartServerResponse(('TokenMismatch',))
144
136
        except errors.UnlockableTransport:
145
137
            return FailedSmartServerResponse(('UnlockableTransport',))
146
 
        except errors.LockFailed, e:
147
 
            return FailedSmartServerResponse(('LockFailed', str(e.lock), str(e.why)))
148
 
        if repo_token is None:
149
 
            repo_token = ''
150
 
        else:
151
 
            branch.repository.leave_lock_in_place()
 
138
        branch.repository.leave_lock_in_place()
152
139
        branch.leave_lock_in_place()
153
140
        branch.unlock()
154
141
        return SuccessfulSmartServerResponse(('ok', branch_token, repo_token))
165
152
                branch.repository.unlock()
166
153
        except errors.TokenMismatch:
167
154
            return FailedSmartServerResponse(('TokenMismatch',))
168
 
        if repo_token:
169
 
            branch.repository.dont_leave_lock_in_place()
 
155
        branch.repository.dont_leave_lock_in_place()
170
156
        branch.dont_leave_lock_in_place()
171
157
        branch.unlock()
172
158
        return SuccessfulSmartServerResponse(('ok',))