~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/bzrdir.py

  • Committer: Robert Collins
  • Date: 2009-03-06 03:55:27 UTC
  • mto: (4086.1.1 hpss-integration)
  • mto: This revision was merged to the branch mainline in revision 4087.
  • Revision ID: robertc@robertcollins.net-20090306035527-sm1gsd3nh3f2mxpa
Make accessing a branch.tags.get_tag_dict use a smart[er] method rather than VFS calls and real objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
56
56
    def do(self, path, *args):
57
57
        """Open a BzrDir at path, and return self.do_bzrdir_request(*args)."""
58
 
        self._bzrdir = BzrDir.open_from_transport(
59
 
            self.transport_from_client_path(path))
 
58
        try:
 
59
            self._bzrdir = BzrDir.open_from_transport(
 
60
                self.transport_from_client_path(path))
 
61
        except errors.NotBranchError:
 
62
            return FailedSmartServerResponse(('nobranch', ))
60
63
        return self.do_bzrdir_request(*args)
61
64
 
62
65
    def _boolean_to_yes_no(self, a_boolean):
298
301
        return SuccessfulSmartServerResponse(('ok', ))
299
302
 
300
303
 
301
 
class SmartServerRequestOpenBranch(SmartServerRequest):
302
 
 
303
 
    def do(self, path):
304
 
        """try to open a branch at path and return ok/nobranch.
305
 
 
306
 
        If a bzrdir is not present, an exception is propogated
307
 
        rather than 'no branch' because these are different conditions.
308
 
        """
309
 
        bzrdir = BzrDir.open_from_transport(
310
 
            self.transport_from_client_path(path))
 
304
class SmartServerRequestOpenBranch(SmartServerRequestBzrDir):
 
305
 
 
306
    def do_bzrdir_request(self):
 
307
        """open a branch at path and return the branch reference or branch."""
311
308
        try:
312
 
            reference_url = bzrdir.get_branch_reference()
 
309
            reference_url = self._bzrdir.get_branch_reference()
313
310
            if reference_url is None:
314
311
                return SuccessfulSmartServerResponse(('ok', ''))
315
312
            else:
316
313
                return SuccessfulSmartServerResponse(('ok', reference_url))
317
314
        except errors.NotBranchError:
318
315
            return FailedSmartServerResponse(('nobranch', ))
 
316
 
 
317
 
 
318
class SmartServerRequestOpenBranchV2(SmartServerRequestBzrDir):
 
319
 
 
320
    def do_bzrdir_request(self):
 
321
        """open a branch at path and return the reference or format."""
 
322
        try:
 
323
            reference_url = self._bzrdir.get_branch_reference()
 
324
            if reference_url is None:
 
325
                format = self._bzrdir.open_branch()._format.network_name()
 
326
                return SuccessfulSmartServerResponse(('branch', format))
 
327
            else:
 
328
                return SuccessfulSmartServerResponse(('ref', reference_url))
 
329
        except errors.NotBranchError:
 
330
            return FailedSmartServerResponse(('nobranch', ))