/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 commands.py

Add docstring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
from bzrlib.plugins.git import (
32
32
    get_rich_root_format,
33
 
    lazy_check_versions,
34
33
    )
35
34
 
36
35
class cmd_git_import(Command):
48
47
            )
49
48
        from bzrlib.bzrdir import (
50
49
            BzrDir,
51
 
            format_registry,
52
50
            )
53
51
        from bzrlib.errors import (
54
52
            BzrCommandError,
59
57
            InterRepository,
60
58
            Repository,
61
59
            )
62
 
        from bzrlib.plugins.git.branch import GitBranch
 
60
        from bzrlib.plugins.git.branch import (
 
61
            GitBranch,
 
62
            extract_tags,
 
63
            )
63
64
        from bzrlib.plugins.git.repository import GitRepository
64
65
 
65
66
        if dest_location is None:
74
75
        except NotBranchError:
75
76
            target_bzrdir = BzrDir.create(dest_location, format=format)
76
77
        try:
77
 
            target_repo = target_bzrdir.open_repository()
 
78
            target_repo = target_bzrdir.find_repository()
78
79
        except NoRepositoryPresent:
79
80
            target_repo = target_bzrdir.create_repository(shared=True)
80
81
 
 
82
        if not target_repo.supports_rich_root():
 
83
            raise BzrCommandError("Target repository doesn't support rich roots")
 
84
 
81
85
        interrepo = InterRepository.get(source_repo, target_repo)
82
86
        mapping = source_repo.get_mapping()
83
87
        refs = interrepo.fetch_refs()
 
88
        tags = {}
 
89
        for k, v in extract_tags(refs).iteritems():
 
90
            tags[k] = mapping.revision_id_foreign_to_bzr(v)
84
91
        pb = ui.ui_factory.nested_progress_bar()
85
92
        try:
86
93
            for i, (name, ref) in enumerate(refs.iteritems()):
100
107
                except NotBranchError:
101
108
                    head_branch = head_bzrdir.create_branch()
102
109
                revid = mapping.revision_id_foreign_to_bzr(ref)
103
 
                source_branch = GitBranch(source_repo.bzrdir, source_repo, 
104
 
                    name, None)
 
110
                source_branch = GitBranch(source_repo.bzrdir, source_repo,
 
111
                    name, None, tags)
105
112
                source_branch.head = ref
106
 
                head_branch.generate_revision_history(revid)
 
113
                if head_branch.last_revision() != revid:
 
114
                    head_branch.generate_revision_history(revid)
107
115
                source_branch.tags.merge_to(head_branch.tags)
108
116
        finally:
109
117
            pb.finished()
111
119
 
112
120
class cmd_git_object(Command):
113
121
    """List or display Git objects by SHA.
114
 
    
 
122
 
115
123
    Cat a particular object's Git representation if a SHA is specified.
116
124
    List all available SHAs otherwise.
117
125
    """
120
128
 
121
129
    aliases = ["git-objects", "git-cat"]
122
130
    takes_args = ["sha1?"]
123
 
    takes_options = [Option('directory', 
 
131
    takes_options = [Option('directory',
124
132
        short_name='d',
125
133
        help='Location of repository.', type=unicode),
126
134
        Option('pretty', help='Pretty-print objects.')]