~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/bzrdir.py

  • Committer: Robert Collins
  • Date: 2007-04-24 12:20:09 UTC
  • mto: (2432.3.5 hpss-vfs-fallback)
  • mto: This revision was merged to the branch mainline in revision 2463.
  • Revision ID: robertc@lifelesswks.robertcollins.net-20070424122009-8bb4dede6a298d93
Make using SuccessfulSmartServerResponse and FailedSmartServerResponse mandatory rather than optional in smart server logic.

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, BzrDirFormat
22
 
from bzrlib.smart.request import SmartServerRequest, SmartServerResponse
 
22
from bzrlib.smart.request import (
 
23
    FailedSmartServerResponse,
 
24
    SmartServerRequest,
 
25
    SuccessfulSmartServerResponse,
 
26
    )
23
27
 
24
28
 
25
29
class SmartServerRequestOpenBzrDir(SmartServerRequest):
35
39
            answer = 'no'
36
40
        else:
37
41
            answer = 'yes'
38
 
        return SmartServerResponse((answer,))
 
42
        return SuccessfulSmartServerResponse((answer,))
39
43
 
40
44
 
41
45
class SmartServerRequestFindRepository(SmartServerRequest):
68
72
                tree_ref = 'yes'
69
73
            else:
70
74
                tree_ref = 'no'
71
 
            return SmartServerResponse(('ok', '/'.join(segments), rich_root, tree_ref))
 
75
            return SuccessfulSmartServerResponse(('ok', '/'.join(segments), rich_root, tree_ref))
72
76
        except errors.NoRepositoryPresent:
73
 
            return SmartServerResponse(('norepository', ))
 
77
            return FailedSmartServerResponse(('norepository', ))
74
78
 
75
79
 
76
80
class SmartServerRequestInitializeBzrDir(SmartServerRequest):
83
87
        """
84
88
        target_transport = self._backing_transport.clone(path)
85
89
        BzrDirFormat.get_default_format().initialize_on_transport(target_transport)
86
 
        return SmartServerResponse(('ok', ))
 
90
        return SuccessfulSmartServerResponse(('ok', ))
87
91
 
88
92
 
89
93
class SmartServerRequestOpenBranch(SmartServerRequest):
98
102
        try:
99
103
            reference_url = bzrdir.get_branch_reference()
100
104
            if reference_url is None:
101
 
                return SmartServerResponse(('ok', ''))
 
105
                return SuccessfulSmartServerResponse(('ok', ''))
102
106
            else:
103
 
                return SmartServerResponse(('ok', reference_url))
 
107
                return SuccessfulSmartServerResponse(('ok', reference_url))
104
108
        except errors.NotBranchError:
105
 
            return SmartServerResponse(('nobranch', ))
 
109
            return FailedSmartServerResponse(('nobranch', ))