~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-28 13:05:15 UTC
  • mfrom: (6313 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6314.
  • Revision ID: jelmer@samba.org-20111128130515-s29pwv14nl5w4mbl
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
 
122
122
    def get_format_description(self):
123
123
        if self._network_name:
124
 
            real_format = controldir.network_format_registry.get(self._network_name)
125
 
            return 'Remote: ' + real_format.get_format_description()
 
124
            try:
 
125
                real_format = controldir.network_format_registry.get(
 
126
                        self._network_name)
 
127
            except KeyError:
 
128
                pass
 
129
            else:
 
130
                return 'Remote: ' + real_format.get_format_description()
126
131
        return 'bzr remote bzrdir'
127
132
 
128
133
    def get_format_string(self):
518
523
        if len(branch_info) != 2:
519
524
            raise errors.UnexpectedSmartServerResponse(response)
520
525
        branch_ref, branch_name = branch_info
521
 
        format = controldir.network_format_registry.get(control_name)
 
526
        try:
 
527
            format = controldir.network_format_registry.get(control_name)
 
528
        except KeyError:
 
529
            raise errors.UnknownFormatError(kind='control', format=control_name)
 
530
 
522
531
        if repo_name:
523
 
            format.repository_format = _mod_repository.network_format_registry.get(
524
 
                repo_name)
 
532
            try:
 
533
                format.repository_format = _mod_repository.network_format_registry.get(
 
534
                    repo_name)
 
535
            except KeyError:
 
536
                raise errors.UnknownFormatError(kind='repository',
 
537
                    format=repo_name)
525
538
        if branch_ref == 'ref':
526
539
            # XXX: we need possible_transports here to avoid reopening the
527
540
            # connection to the referenced location
530
543
            format.set_branch_format(branch_format)
531
544
        elif branch_ref == 'branch':
532
545
            if branch_name:
533
 
                format.set_branch_format(
534
 
                    branch.network_format_registry.get(branch_name))
 
546
                try:
 
547
                    branch_format = branch.network_format_registry.get(
 
548
                        branch_name)
 
549
                except KeyError:
 
550
                    raise errors.UnknownFormatError(kind='branch',
 
551
                        format=branch_name)
 
552
                format.set_branch_format(branch_format)
535
553
        else:
536
554
            raise errors.UnexpectedSmartServerResponse(response)
537
555
        return format
969
987
 
970
988
    def _ensure_real(self):
971
989
        if self._custom_format is None:
972
 
            self._custom_format = _mod_repository.network_format_registry.get(
973
 
                self._network_name)
 
990
            try:
 
991
                self._custom_format = _mod_repository.network_format_registry.get(
 
992
                    self._network_name)
 
993
            except KeyError:
 
994
                raise errors.UnknownFormatError(kind='repository',
 
995
                    format=self._network_name)
974
996
 
975
997
    @property
976
998
    def _fetch_order(self):
2671
2693
 
2672
2694
    def _ensure_real(self):
2673
2695
        if self._custom_format is None:
2674
 
            self._custom_format = branch.network_format_registry.get(
2675
 
                self._network_name)
 
2696
            try:
 
2697
                self._custom_format = branch.network_format_registry.get(
 
2698
                    self._network_name)
 
2699
            except KeyError:
 
2700
                raise errors.UnknownFormatError(kind='branch',
 
2701
                    format=self._network_name)
2676
2702
 
2677
2703
    def get_format_description(self):
2678
2704
        self._ensure_real()