/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

Fix compatibility with newer versions of breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
                     Option('colocated', help='Create colocated branches.'),
43
43
                     ]
44
44
 
45
 
    def _get_colocated_branch(self, target_bzrdir, name):
 
45
    def _get_colocated_branch(self, target_controldir, name):
46
46
        from ...errors import NotBranchError
47
47
        try:
48
 
            return target_bzrdir.open_branch(name=name)
 
48
            return target_controldir.open_branch(name=name)
49
49
        except NotBranchError:
50
 
            return target_bzrdir.create_branch(name=name)
 
50
            return target_controldir.create_branch(name=name)
51
51
 
52
52
    def _get_nested_branch(self, dest_transport, dest_format, name):
53
 
        from ...bzrdir import BzrDir
 
53
        from ...controldir import ControlDir
54
54
        from ...errors import NotBranchError
55
55
        head_transport = dest_transport.clone(name)
56
56
        try:
57
 
            head_bzrdir = BzrDir.open_from_transport(head_transport)
 
57
            head_controldir = ControlDir.open_from_transport(head_transport)
58
58
        except NotBranchError:
59
 
            head_bzrdir = dest_format.initialize_on_transport_ex(
 
59
            head_controldir = dest_format.initialize_on_transport_ex(
60
60
                head_transport, create_prefix=True)[1]
61
61
        try:
62
 
            return head_bzrdir.open_branch()
 
62
            return head_controldir.open_branch()
63
63
        except NotBranchError:
64
 
            return head_bzrdir.create_branch()
 
64
            return head_controldir.create_branch()
65
65
 
66
66
    def run(self, src_location, dest_location=None, colocated=False):
67
67
        import os
72
72
            ui,
73
73
            urlutils,
74
74
            )
75
 
        from ...bzrdir import (
76
 
            BzrDir,
 
75
        from ...controldir import (
 
76
            ControlDir,
77
77
            )
78
78
        from ...errors import (
79
79
            BzrCommandError,
105
105
        if not isinstance(source_repo, GitRepository):
106
106
            raise BzrCommandError(gettext("%r is not a git repository") % src_location)
107
107
        try:
108
 
            target_bzrdir = BzrDir.open_from_transport(dest_transport)
 
108
            target_controldir = ControlDir.open_from_transport(dest_transport)
109
109
        except NotBranchError:
110
 
            target_bzrdir = dest_format.initialize_on_transport_ex(
 
110
            target_controldir = dest_format.initialize_on_transport_ex(
111
111
                dest_transport, shared_repo=True)[1]
112
112
        try:
113
 
            target_repo = target_bzrdir.find_repository()
 
113
            target_repo = target_controldir.find_repository()
114
114
        except NoRepositoryPresent:
115
 
            target_repo = target_bzrdir.create_repository(shared=True)
 
115
            target_repo = target_controldir.create_repository(shared=True)
116
116
 
117
117
        if not target_repo.supports_rich_root():
118
118
            raise BzrCommandError(gettext("Target repository doesn't support rich roots"))
130
130
                    # Not a branch, ignore
131
131
                    continue
132
132
                pb.update(gettext("creating branches"), i, len(refs_dict))
133
 
                if getattr(target_bzrdir._format, "colocated_branches", False) and colocated:
 
133
                if getattr(target_controldir._format, "colocated_branches", False) and colocated:
134
134
                    if name == "HEAD":
135
135
                        branch_name = None
136
 
                    head_branch = self._get_colocated_branch(target_bzrdir, branch_name)
 
136
                    head_branch = self._get_colocated_branch(target_controldir, branch_name)
137
137
                else:
138
138
                    head_branch = self._get_nested_branch(dest_transport, dest_format, branch_name)
139
139
                revid = mapping.revision_id_foreign_to_bzr(sha)
140
 
                source_branch = GitBranch(source_repo.bzrdir, source_repo,
 
140
                source_branch = GitBranch(source_repo.controldir, source_repo,
141
141
                    sha)
142
142
                source_branch.head = sha
143
143
                if head_branch.last_revision() != revid:
176
176
        from ...errors import (
177
177
            BzrCommandError,
178
178
            )
179
 
        from ...bzrdir import (
180
 
            BzrDir,
 
179
        from ...controldir import (
 
180
            ControlDir,
181
181
            )
182
182
        from .object_store import (
183
183
            get_object_store,
184
184
            )
185
185
        from . import gettext
186
 
        bzrdir, _ = BzrDir.open_containing(directory)
187
 
        repo = bzrdir.find_repository()
 
186
        controldir, _ = ControlDir.open_containing(directory)
 
187
        repo = controldir.find_repository()
188
188
        object_store = get_object_store(repo)
189
189
        object_store.lock_read()
190
190
        try:
216
216
 
217
217
    @display_command
218
218
    def run(self, location="."):
219
 
        from ...bzrdir import (
220
 
            BzrDir,
 
219
        from ...controldir import (
 
220
            ControlDir,
221
221
            )
222
222
        from .refs import (
223
223
            get_refs_container,
225
225
        from .object_store import (
226
226
            get_object_store,
227
227
            )
228
 
        bzrdir, _ = BzrDir.open_containing(location)
229
 
        repo = bzrdir.find_repository()
 
228
        controldir, _ = ControlDir.open_containing(location)
 
229
        repo = controldir.find_repository()
230
230
        object_store = get_object_store(repo)
231
231
        object_store.lock_read()
232
232
        try:
233
 
            refs = get_refs_container(bzrdir, object_store)
 
233
            refs = get_refs_container(controldir, object_store)
234
234
            for k, v in refs.as_dict().iteritems():
235
235
                self.outf.write("%s -> %s\n" % (k, v))
236
236
        finally: