/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: Robert Collins
  • Date: 2009-04-23 06:07:44 UTC
  • mto: This revision was merged to the branch mainline in revision 4304.
  • Revision ID: robertc@robertcollins.net-20090423060744-ile6rixv4jqyqpts
Reasonable unit test coverage for initialize_on_transport_ex.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    lockdir,
45
45
    osutils,
46
46
    remote,
 
47
    repository,
47
48
    revision as _mod_revision,
48
49
    ui,
49
50
    urlutils,
1824
1825
    def initialize(self, url, possible_transports=None):
1825
1826
        """Create a bzr control dir at this url and return an opened copy.
1826
1827
 
 
1828
        While not deprecated, this method is very specific and its use will
 
1829
        lead to many round trips to setup a working environment. See
 
1830
        initialize_on_transport_ex for a [nearly] all-in-one method.
 
1831
 
1827
1832
        Subclasses should typically override initialize_on_transport
1828
1833
        instead of this method.
1829
1834
        """
1850
1855
 
1851
1856
    def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1852
1857
        create_prefix=False, force_new_repo=False, stacked_on=None,
1853
 
        stack_on_pwd=None, repo_format_name=None, make_working_trees=False,
 
1858
        stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1854
1859
        shared_repo=False):
1855
1860
        """Create this format on transport.
1856
1861
 
1868
1873
            the repo_format_name is used to select the format of repository to
1869
1874
            create.
1870
1875
        :param make_working_trees: Control the setting of make_working_trees
1871
 
            for a new shared repository when one is made.
 
1876
            for a new shared repository when one is made. None to use whatever
 
1877
            default the format has.
1872
1878
        :param shared_repo: Control whether made repositories are shared or
1873
1879
            not.
1874
 
        :return: repo, bzrdir, require_stacking. repo is None if none was
1875
 
            created or found, bzrdir is always valid. require_stacking is the
1876
 
            result of examining the stacked_on parameter and any stacking
1877
 
            policy found for the target.
 
1880
        :return: repo, bzrdir, require_stacking, repository_policy. repo is
 
1881
            None if none was created or found, bzrdir is always valid.
 
1882
            require_stacking is the result of examining the stacked_on
 
1883
            parameter and any stacking policy found for the target.
1878
1884
        """
1879
1885
        # XXX: Refactor the create_prefix/no_create_prefix code into a
1880
1886
        #      common helper function
1900
1906
        # Now the target directory exists, but doesn't have a .bzr
1901
1907
        # directory. So we need to create it, along with any work to create
1902
1908
        # all of the dependent branches, etc.
 
1909
 
1903
1910
        result = self.initialize_on_transport(transport)
1904
1911
        if repo_format_name:
 
1912
            try:
 
1913
                # use a custom format
 
1914
                result._format.repository_format = \
 
1915
                    repository.network_format_registry.get(repo_format_name)
 
1916
            except AttributeError:
 
1917
                # The format didn't permit it to be set.
 
1918
                pass
1905
1919
            # A repository is desired, either in-place or shared.
1906
1920
            repository_policy = result.determine_repository_policy(
1907
1921
                force_new_repo, stacked_on, stack_on_pwd,
2133
2147
    repository_format = property(__return_repository_format)
2134
2148
 
2135
2149
 
2136
 
class BzrDirFormat5(BzrDirFormat):
 
2150
class BzrDirFormatAllInOne(BzrDirFormat):
 
2151
    """Common class for formats before meta-dirs."""
 
2152
 
 
2153
    def initialize_on_transport_ex(self, transport, use_existing_dir=False,
 
2154
        create_prefix=False, force_new_repo=False, stacked_on=None,
 
2155
        stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
 
2156
        shared_repo=False):
 
2157
        """See BzrDirFormat.initialize_on_transport_ex."""
 
2158
        require_stacking = (stacked_on is not None)
 
2159
        # Format 5 cannot stack, but we've been asked do - actually init
 
2160
        # a Meta1Dir
 
2161
        if require_stacking:
 
2162
            format = BzrDirMetaFormat1()
 
2163
            return format.initialize_on_transport_ex(transport,
 
2164
                use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
2165
                force_new_repo=force_new_repo, stacked_on=stacked_on,
 
2166
                stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
2167
                make_working_trees=make_working_trees, shared_repo=shared_repo)
 
2168
        return BzrDirFormat.initialize_on_transport_ex(self, transport,
 
2169
            use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
2170
            force_new_repo=force_new_repo, stacked_on=stacked_on,
 
2171
            stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
2172
            make_working_trees=make_working_trees, shared_repo=shared_repo)
 
2173
 
 
2174
 
 
2175
class BzrDirFormat5(BzrDirFormatAllInOne):
2137
2176
    """Bzr control format 5.
2138
2177
 
2139
2178
    This format is a combined format for working tree, branch and repository.
2194
2233
    repository_format = property(__return_repository_format)
2195
2234
 
2196
2235
 
2197
 
class BzrDirFormat6(BzrDirFormat):
 
2236
class BzrDirFormat6(BzrDirFormatAllInOne):
2198
2237
    """Bzr control format 6.
2199
2238
 
2200
2239
    This format is a combined format for working tree, branch and repository.