/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: 2008-09-11 19:36:38 UTC
  • mfrom: (3703 +trunk)
  • mto: (3705.1.1 trunk2)
  • mto: This revision was merged to the branch mainline in revision 3708.
  • Revision ID: v.ladeuil+lp@free.fr-20080911193638-wtjyc1kcmacc6t1f
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
                                       preserve_stacking=preserve_stacking)
178
178
 
179
179
    def clone_on_transport(self, transport, revision_id=None,
180
 
                           force_new_repo=False, preserve_stacking=False):
 
180
                           force_new_repo=False, preserve_stacking=False,
 
181
                           stacked_on=None):
181
182
        """Clone this bzrdir and its contents to transport verbatim.
182
183
 
183
184
        :param transport: The transport for the location to produce the clone
191
192
            new branch on top of the other branch's stacked-on branch.
192
193
        """
193
194
        transport.ensure_base()
194
 
        result = self.cloning_metadir().initialize_on_transport(transport)
 
195
        require_stacking = (stacked_on is not None)
 
196
        metadir = self.cloning_metadir(require_stacking)
 
197
        result = metadir.initialize_on_transport(transport)
195
198
        repository_policy = None
196
 
        stack_on = None
197
199
        try:
198
200
            local_repo = self.find_repository()
199
201
        except errors.NoRepositoryPresent:
208
210
                local_repo = local_branch.repository
209
211
            if preserve_stacking:
210
212
                try:
211
 
                    stack_on = local_branch.get_stacked_on_url()
 
213
                    stacked_on = local_branch.get_stacked_on_url()
212
214
                except (errors.UnstackableBranchFormat,
213
215
                        errors.UnstackableRepositoryFormat,
214
216
                        errors.NotStacked):
217
219
        if local_repo:
218
220
            # may need to copy content in
219
221
            repository_policy = result.determine_repository_policy(
220
 
                force_new_repo, stack_on, self.root_transport.base)
 
222
                force_new_repo, stacked_on, self.root_transport.base,
 
223
                require_stacking=require_stacking)
221
224
            make_working_trees = local_repo.make_working_trees()
222
225
            result_repo = repository_policy.acquire_repository(
223
226
                make_working_trees, local_repo.is_shared())
1046
1049
            mutter("using %r for stacking" % (format._branch_format,))
1047
1050
            from bzrlib.repofmt import pack_repo
1048
1051
            if format.repository_format.rich_root_data:
 
1052
                bzrdir_format_name = '1.6.1-rich-root'
1049
1053
                repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
1050
1054
            else:
 
1055
                bzrdir_format_name = '1.6'
1051
1056
                repo_format = pack_repo.RepositoryFormatKnitPack5()
 
1057
            note('Source format does not support stacking, using format:'
 
1058
                 ' \'%s\'\n  %s\n',
 
1059
                 bzrdir_format_name, repo_format.get_format_description())
1052
1060
            format.repository_format = repo_format
1053
1061
        return format
1054
1062
 
1198
1206
        preserve_stacking has no effect, since no source branch using this
1199
1207
        family of formats can be stacked, so there is no stacking to preserve.
1200
1208
        """
1201
 
        from bzrlib.workingtree import WorkingTreeFormat2
1202
1209
        self._make_tail(url)
1203
1210
        result = self._format._initialize_for_clone(url)
1204
1211
        self.open_repository().clone(result, revision_id=revision_id)
1205
1212
        from_branch = self.open_branch()
1206
1213
        from_branch.clone(result, revision_id=revision_id)
1207
1214
        try:
1208
 
            self.open_workingtree().clone(result)
 
1215
            tree = self.open_workingtree()
1209
1216
        except errors.NotLocalUrl:
1210
1217
            # make a new one, this format always has to have one.
1211
 
            try:
1212
 
                WorkingTreeFormat2().initialize(result)
1213
 
            except errors.NotLocalUrl:
1214
 
                # but we cannot do it for remote trees.
1215
 
                to_branch = result.open_branch()
1216
 
                WorkingTreeFormat2()._stub_initialize_remote(to_branch)
 
1218
            result._init_workingtree()
 
1219
        else:
 
1220
            tree.clone(result)
1217
1221
        return result
1218
1222
 
1219
1223
    def create_branch(self):
1237
1241
    def create_workingtree(self, revision_id=None, from_branch=None,
1238
1242
                           accelerator_tree=None, hardlink=False):
1239
1243
        """See BzrDir.create_workingtree."""
 
1244
        # The workingtree is sometimes created when the bzrdir is created,
 
1245
        # but not when cloning.
 
1246
 
1240
1247
        # this looks buggy but is not -really-
1241
1248
        # because this format creates the workingtree when the bzrdir is
1242
1249
        # created
1246
1253
        # that can do wonky stuff here, and that only
1247
1254
        # happens for creating checkouts, which cannot be 
1248
1255
        # done on this format anyway. So - acceptable wart.
1249
 
        result = self.open_workingtree(recommend_upgrade=False)
 
1256
        try:
 
1257
            result = self.open_workingtree(recommend_upgrade=False)
 
1258
        except errors.NoSuchFile:
 
1259
            result = self._init_workingtree()
1250
1260
        if revision_id is not None:
1251
1261
            if revision_id == _mod_revision.NULL_REVISION:
1252
1262
                result.set_parent_ids([])
1254
1264
                result.set_parent_ids([revision_id])
1255
1265
        return result
1256
1266
 
 
1267
    def _init_workingtree(self):
 
1268
        from bzrlib.workingtree import WorkingTreeFormat2
 
1269
        try:
 
1270
            return WorkingTreeFormat2().initialize(self)
 
1271
        except errors.NotLocalUrl:
 
1272
            # Even though we can't access the working tree, we need to
 
1273
            # create its control files.
 
1274
            return WorkingTreeFormat2()._stub_initialize_on_transport(
 
1275
                self.transport, self._control_files._file_mode)
 
1276
 
1257
1277
    def destroy_workingtree(self):
1258
1278
        """See BzrDir.destroy_workingtree."""
1259
1279
        raise errors.UnsupportedOperation(self.destroy_workingtree, self)
1889
1909
        """
1890
1910
        from bzrlib.branch import BzrBranchFormat4
1891
1911
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
1892
 
        from bzrlib.workingtree import WorkingTreeFormat2
1893
1912
        result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1894
1913
        RepositoryFormat5().initialize(result, _internal=True)
1895
1914
        if not _cloning:
1896
1915
            branch = BzrBranchFormat4().initialize(result)
1897
 
            try:
1898
 
                WorkingTreeFormat2().initialize(result)
1899
 
            except errors.NotLocalUrl:
1900
 
                # Even though we can't access the working tree, we need to
1901
 
                # create its control files.
1902
 
                WorkingTreeFormat2()._stub_initialize_remote(branch)
 
1916
            result._init_workingtree()
1903
1917
        return result
1904
1918
 
1905
1919
    def _open(self, transport):
1952
1966
        """
1953
1967
        from bzrlib.branch import BzrBranchFormat4
1954
1968
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
1955
 
        from bzrlib.workingtree import WorkingTreeFormat2
1956
1969
        result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1957
1970
        RepositoryFormat6().initialize(result, _internal=True)
1958
1971
        if not _cloning:
1959
1972
            branch = BzrBranchFormat4().initialize(result)
1960
 
            try:
1961
 
                WorkingTreeFormat2().initialize(result)
1962
 
            except errors.NotLocalUrl:
1963
 
                # Even though we can't access the working tree, we need to
1964
 
                # create its control files.
1965
 
                WorkingTreeFormat2()._stub_initialize_remote(branch)
 
1973
            result._init_workingtree()
1966
1974
        return result
1967
1975
 
1968
1976
    def _open(self, transport):