/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-04 12:28:56 UTC
  • mfrom: (2584 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070704122856-7jn5e6ou08ukimof
merge bzr.dev @ 2584 resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
directories.
21
21
"""
22
22
 
23
 
# TODO: remove unittest dependency; put that stuff inside the test suite
24
 
 
25
23
# TODO: Can we move specific formats into separate modules to make this file
26
24
# smaller?
27
25
 
31
29
 
32
30
from bzrlib.lazy_import import lazy_import
33
31
lazy_import(globals(), """
34
 
from copy import deepcopy
35
32
from stat import S_ISDIR
36
 
import unittest
37
33
 
38
34
import bzrlib
39
35
from bzrlib import (
1704
1700
BzrDirFormat._default_format = __default_format
1705
1701
 
1706
1702
 
1707
 
class BzrDirTestProviderAdapter(object):
1708
 
    """A tool to generate a suite testing multiple bzrdir formats at once.
1709
 
 
1710
 
    This is done by copying the test once for each transport and injecting
1711
 
    the transport_server, transport_readonly_server, and bzrdir_format
1712
 
    classes into each copy. Each copy is also given a new id() to make it
1713
 
    easy to identify.
1714
 
    """
1715
 
 
1716
 
    def __init__(self, vfs_factory, transport_server, transport_readonly_server,
1717
 
        formats):
1718
 
        """Create an object to adapt tests.
1719
 
 
1720
 
        :param vfs_server: A factory to create a Transport Server which has
1721
 
            all the VFS methods working, and is writable.
1722
 
        """
1723
 
        self._vfs_factory = vfs_factory
1724
 
        self._transport_server = transport_server
1725
 
        self._transport_readonly_server = transport_readonly_server
1726
 
        self._formats = formats
1727
 
    
1728
 
    def adapt(self, test):
1729
 
        result = unittest.TestSuite()
1730
 
        for format in self._formats:
1731
 
            new_test = deepcopy(test)
1732
 
            new_test.vfs_transport_factory = self._vfs_factory
1733
 
            new_test.transport_server = self._transport_server
1734
 
            new_test.transport_readonly_server = self._transport_readonly_server
1735
 
            new_test.bzrdir_format = format
1736
 
            def make_new_test_id():
1737
 
                new_id = "%s(%s)" % (new_test.id(), format.__class__.__name__)
1738
 
                return lambda: new_id
1739
 
            new_test.id = make_new_test_id()
1740
 
            result.addTest(new_test)
1741
 
        return result
1742
 
 
1743
 
 
1744
1703
class Converter(object):
1745
1704
    """Converts a disk format object from one format to another."""
1746
1705