/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 breezy/git/dir.py

Add a 'brz clone' command.

Merged from https://code.launchpad.net/~jelmer/brz/clone/+merge/379369

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
        """See ControlDir.clone_on_transport."""
229
229
        from ..repository import InterRepository
230
230
        from .mapping import default_mapping
 
231
        from ..transport.local import LocalTransport
231
232
        if stacked_on is not None:
232
233
            raise _mod_branch.UnstackableBranchFormat(
233
234
                self._format, self.user_url)
253
254
                                                       mapping=default_mapping)
254
255
        for name, val in viewitems(refs):
255
256
            target_git_repo.refs[name] = val
256
 
        result_dir = self.__class__(transport, target_git_repo, format)
 
257
        result_dir = LocalGitDir(transport, target_git_repo, format)
257
258
        if revision_id is not None:
258
259
            result_dir.open_branch().set_last_revision(revision_id)
259
 
        try:
260
 
            # Cheaper to check if the target is not local, than to try making
261
 
            # the tree and fail.
262
 
            result_dir.root_transport.local_abspath('.')
 
260
        if not no_tree and isinstance(result_dir.root_transport, LocalTransport):
263
261
            if result_dir.open_repository().make_working_trees():
264
 
                self.open_workingtree().clone(
265
 
                    result_dir, revision_id=revision_id)
266
 
        except (brz_errors.NoWorkingTree, brz_errors.NotLocalUrl):
267
 
            pass
 
262
                try:
 
263
                    local_wt = self.open_workingtree()
 
264
                except brz_errors.NoWorkingTree:
 
265
                    pass
 
266
                except brz_errors.NotLocalUrl:
 
267
                    result_dir.create_workingtree(revision_id=revision_id)
 
268
                else:
 
269
                    local_wt.clone(result_dir, revision_id=revision_id)
268
270
 
269
271
        return result_dir
270
272
 
299
301
        """
300
302
        return UseExistingRepository(self.find_repository())
301
303
 
 
304
    def branch_names(self):
 
305
        from .refs import ref_to_branch_name
 
306
        ret = []
 
307
        for ref in self.get_refs_container().keys():
 
308
            try:
 
309
                branch_name = ref_to_branch_name(ref)
 
310
            except UnicodeDecodeError:
 
311
                trace.warning("Ignoring branch %r with unicode error ref", ref)
 
312
                continue
 
313
            except ValueError:
 
314
                continue
 
315
            ret.append(branch_name)
 
316
        return ret
 
317
 
302
318
    def get_branches(self):
303
319
        from .refs import ref_to_branch_name
304
320
        ret = {}