~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-01-10 10:42:08 UTC
  • mto: (2323.7.1 redirection)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: v.ladeuil+lp@free.fr-20070110104208-m510xzaw55nca20d
Simplify the get wrapping and restrict redirection to bzr branches.

* bzrlib/transport/local.py:
(LocalTransport.get): Really declare the hint parameters or the
deprecation warning make some tests fail (they rely on a specific
output from the command issued, with is, IMHO, bad, but that's not
the problem I try to address now).

* bzrlib/transport/__init__.py:
(_inject_get_with_hints): Deleted.
(_add_hints_to_get.get): Renamed from _check_get_with_hints and
simplified. KISS principle is good, use it.
(register_lazy_transport._loader): Issue a deprecation warning if
needed.
(Transport.create_get_hints): Usage is to use the name 'klass' for
class methods.

* bzrlib/bzrdir.py:
(BzrDirFormat.probe_transport): Leave that one alone.
(BzrDirMetaFormat1.probe_transport): New method so that
redirection is applied to bzr branches only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1102
1102
    def probe_transport(klass, transport):
1103
1103
        """Return the .bzrdir style transport present at URL."""
1104
1104
        try:
1105
 
            hints = transport.create_get_hints(follow_redirections=False)
1106
 
            format_file = transport.get(".bzr/branch-format",**hints)
 
1105
            format_file = transport.get(".bzr/branch-format")
1107
1106
            format_string = format_file.read()
1108
1107
        except errors.NoSuchFile:
1109
1108
            raise errors.NotBranchError(path=transport.base)
1490
1489
        """Allow changint the repository format for metadir formats."""
1491
1490
        self._repository_format = value
1492
1491
 
 
1492
    @classmethod
 
1493
    def probe_transport(klass, transport):
 
1494
        """Return the .bzrdir style transport present at URL.
 
1495
 
 
1496
        Redirections are not followed.
 
1497
        """
 
1498
        try:
 
1499
            hints = transport.create_get_hints(follow_redirections=False)
 
1500
            format_file = transport.get(".bzr/branch-format",**hints)
 
1501
            format_string = format_file.read()
 
1502
        except errors.NoSuchFile:
 
1503
            raise errors.NotBranchError(path=transport.base)
 
1504
 
 
1505
        try:
 
1506
            return klass._formats[format_string]
 
1507
        except KeyError:
 
1508
            raise errors.UnknownFormatError(format=format_string)
 
1509
 
1493
1510
    repository_format = property(__return_repository_format, __set_repository_format)
1494
1511
 
1495
1512