/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

Simply refer to bzr's docs in HACKING.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    get_rich_root_format,
33
33
    )
34
34
 
35
 
class cmd_git_serve(Command):
36
 
    """Provide access to a Bazaar branch using the git protocol.
37
 
 
38
 
    This command is experimental and doesn't do much yet.
39
 
    """
40
 
    takes_options = [
41
 
        Option('directory',
42
 
               short_name='d',
43
 
               help='serve contents of directory',
44
 
               type=unicode)
45
 
    ]
46
 
 
47
 
    def run(self, directory=None):
48
 
        lazy_check_versions()
49
 
        from dulwich.server import TCPGitServer
50
 
        from bzrlib.plugins.git.server import BzrBackend
51
 
        from bzrlib.trace import warning
52
 
        import os
53
 
 
54
 
        warning("server support in bzr-git is experimental.")
55
 
 
56
 
        if directory is None:
57
 
            directory = os.getcwd()
58
 
 
59
 
        backend = BzrBackend(directory)
60
 
 
61
 
        server = TCPGitServer(backend, 'localhost')
62
 
        server.serve_forever()
63
 
 
64
 
 
65
35
class cmd_git_import(Command):
66
36
    """Import all branches from a git repository.
67
37
 
77
47
            )
78
48
        from bzrlib.bzrdir import (
79
49
            BzrDir,
80
 
            format_registry,
81
50
            )
82
51
        from bzrlib.errors import (
83
52
            BzrCommandError,
88
57
            InterRepository,
89
58
            Repository,
90
59
            )
91
 
        from bzrlib.plugins.git.branch import GitBranch
 
60
        from bzrlib.plugins.git.branch import (
 
61
            GitBranch,
 
62
            extract_tags,
 
63
            )
92
64
        from bzrlib.plugins.git.repository import GitRepository
93
65
 
94
66
        if dest_location is None:
103
75
        except NotBranchError:
104
76
            target_bzrdir = BzrDir.create(dest_location, format=format)
105
77
        try:
106
 
            target_repo = target_bzrdir.open_repository()
 
78
            target_repo = target_bzrdir.find_repository()
107
79
        except NoRepositoryPresent:
108
80
            target_repo = target_bzrdir.create_repository(shared=True)
109
81
 
 
82
        if not target_repo.supports_rich_root():
 
83
            raise BzrCommandError("Target repository doesn't support rich roots")
 
84
 
110
85
        interrepo = InterRepository.get(source_repo, target_repo)
111
86
        mapping = source_repo.get_mapping()
112
87
        refs = interrepo.fetch_refs()
 
88
        tags = extract_tags(refs, mapping)
113
89
        pb = ui.ui_factory.nested_progress_bar()
114
90
        try:
115
91
            for i, (name, ref) in enumerate(refs.iteritems()):
130
106
                    head_branch = head_bzrdir.create_branch()
131
107
                revid = mapping.revision_id_foreign_to_bzr(ref)
132
108
                source_branch = GitBranch(source_repo.bzrdir, source_repo, 
133
 
                    name, None)
 
109
                    name, None, tags)
134
110
                source_branch.head = ref
135
 
                head_branch.generate_revision_history(revid)
 
111
                if head_branch.last_revision() != revid:
 
112
                    head_branch.generate_revision_history(revid)
136
113
                source_branch.tags.merge_to(head_branch.tags)
137
114
        finally:
138
115
            pb.finished()
173
150
        try:
174
151
            if sha1 is not None:
175
152
                try:
176
 
                    obj = object_store[sha1]
 
153
                    obj = object_store[str(sha1)]
177
154
                except KeyError:
178
155
                    raise BzrCommandError("Object not found: %s" % sha1)
179
156
                if pretty: