/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

UseĀ peeling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
            return head_bzrdir.create_branch()
59
59
 
60
60
    def run(self, src_location, dest_location=None):
61
 
        from collections import defaultdict
62
61
        import os
63
62
        import urllib
64
63
        from bzrlib import (
83
82
        from bzrlib.transport import get_transport
84
83
        from bzrlib.plugins.git.branch import (
85
84
            GitBranch,
86
 
            extract_tags,
87
 
            )
88
 
        from bzrlib.plugins.git.refs import ref_to_branch_name
 
85
            )
 
86
        from bzrlib.plugins.git.refs import (
 
87
            ref_to_branch_name,
 
88
            ref_to_tag_name,
 
89
            )
89
90
        from bzrlib.plugins.git.repository import GitRepository
90
91
 
91
92
        dest_format = controldir.ControlDirFormat.get_default_format()
114
115
        interrepo = InterRepository.get(source_repo, target_repo)
115
116
        mapping = source_repo.get_mapping()
116
117
        refs = interrepo.fetch()
117
 
        unpeeled_tags = defaultdict(set)
118
 
        tags = {}
119
 
        for k, (peeled, unpeeled) in extract_tags(refs).iteritems():
120
 
            tags[k] = mapping.revision_id_foreign_to_bzr(peeled)
121
 
            if unpeeled is not None:
122
 
                unpeeled_tags[peeled].add(unpeeled)
123
 
        # FIXME: Store unpeeled tag map
 
118
        refs_dict = refs.as_dict()
124
119
        pb = ui.ui_factory.nested_progress_bar()
125
120
        try:
126
 
            for i, (name, ref) in enumerate(refs.iteritems()):
 
121
            for i, (name, sha) in enumerate(refs_dict.iteritems()):
127
122
                try:
128
123
                    branch_name = ref_to_branch_name(name)
129
124
                except ValueError:
130
125
                    # Not a branch, ignore
131
126
                    continue
132
 
                pb.update(gettext("creating branches"), i, len(refs))
 
127
                pb.update(gettext("creating branches"), i, len(refs_dict))
133
128
                if getattr(target_bzrdir._format, "colocated_branches", False):
134
129
                    if name == "HEAD":
135
130
                        branch_name = None
136
131
                    head_branch = self._get_colocated_branch(target_bzrdir, branch_name)
137
132
                else:
138
133
                    head_branch = self._get_nested_branch(dest_transport, dest_format, branch_name)
139
 
                revid = mapping.revision_id_foreign_to_bzr(ref)
 
134
                revid = mapping.revision_id_foreign_to_bzr(sha)
140
135
                source_branch = GitBranch(source_repo.bzrdir, source_repo,
141
 
                    ref, tags)
142
 
                source_branch.head = ref
 
136
                    sha)
 
137
                source_branch.head = sha
143
138
                if head_branch.last_revision() != revid:
144
139
                    head_branch.generate_revision_history(revid)
145
140
                source_branch.tags.merge_to(head_branch.tags)
222
217
            BzrDir,
223
218
            )
224
219
        from bzrlib.plugins.git.refs import (
225
 
            get_refs,
 
220
            get_refs_container,
226
221
            )
227
222
        from bzrlib.plugins.git.object_store import (
228
223
            get_object_store,
232
227
        object_store = get_object_store(repo)
233
228
        object_store.lock_read()
234
229
        try:
235
 
            refs = get_refs(bzrdir)
236
 
            for k, v in refs.iteritems():
 
230
            refs = get_refs_container(bzrdir)
 
231
            for k, v in refs.as_dict().iteritems():
237
232
                self.outf.write("%s -> %s\n" % (k, v))
238
233
        finally:
239
234
            object_store.unlock()