/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/plugins/weave_fmt/branch.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Weave-era branch implementations."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
 
from bzrlib import (
 
19
from ... import (
22
20
    errors,
23
21
    lockable_files,
24
22
    )
25
23
 
26
 
from bzrlib.decorators import (
27
 
    needs_read_lock,
28
 
    needs_write_lock,
 
24
from ...decorators import (
29
25
    only_raises,
30
26
    )
31
 
from bzrlib.lock import LogicalLockResult
32
 
from bzrlib.trace import mutter
 
27
from ...lock import LogicalLockResult
 
28
from ...trace import mutter
33
29
 
34
 
from bzrlib.branch import (
 
30
from ...branch import (
35
31
    BranchFormat,
36
32
    BranchWriteLockResult,
37
33
    )
38
 
from bzrlib.branchfmt.fullhistory import (
 
34
from ...bzr.fullhistory import (
39
35
    FullHistoryBzrBranch,
40
36
    )
41
37
 
57
53
        self.repository.lock_write()
58
54
        try:
59
55
            return BranchWriteLockResult(self.unlock,
60
 
                self.control_files.lock_write(token=token))
 
56
                                         self.control_files.lock_write(token=token))
61
57
        except:
62
58
            self.repository.unlock()
63
59
            raise
65
61
    def lock_read(self):
66
62
        """Lock the branch for read operations.
67
63
 
68
 
        :return: A bzrlib.lock.LogicalLockResult.
 
64
        :return: A breezy.lock.LogicalLockResult.
69
65
        """
70
66
        if not self.is_locked():
71
67
            self._note_lock('r')
95
91
    def _get_checkout_format(self, lightweight=False):
96
92
        """Return the most suitable metadir for a checkout of this branch.
97
93
        """
98
 
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
99
 
        from bzrlib.bzrdir import BzrDirMetaFormat1
 
94
        from .repository import RepositoryFormat7
 
95
        from ...bzr.bzrdir import BzrDirMetaFormat1
100
96
        format = BzrDirMetaFormat1()
101
97
        if lightweight:
102
98
            format.set_branch_format(self._format)
103
 
            format.repository_format = self.bzrdir._format.repository_format
 
99
            format.repository_format = self.controldir._format.repository_format
104
100
        else:
105
101
            format.repository_format = RepositoryFormat7()
106
102
        return format
134
130
    It does not support binding.
135
131
    """
136
132
 
137
 
    def initialize(self, a_bzrdir, name=None, repository=None,
 
133
    def initialize(self, a_controldir, name=None, repository=None,
138
134
                   append_revisions_only=None):
139
 
        """Create a branch of this format in a_bzrdir.
 
135
        """Create a branch of this format in a_controldir.
140
136
 
141
 
        :param a_bzrdir: The bzrdir to initialize the branch in
 
137
        :param a_controldir: The bzrdir to initialize the branch in
142
138
        :param name: Name of colocated branch to create, if any
143
139
        :param repository: Repository for this branch (unused)
144
140
        """
145
141
        if append_revisions_only:
146
 
            raise errors.UpgradeRequired(a_bzrdir.user_url)
 
142
            raise errors.UpgradeRequired(a_controldir.user_url)
147
143
        if repository is not None:
148
144
            raise NotImplementedError(
149
145
                "initialize(repository=<not None>) on %r" % (self,))
150
 
        if not [isinstance(a_bzrdir._format, format) for format in
 
146
        if not [isinstance(a_controldir._format, format) for format in
151
147
                self._compatible_bzrdirs]:
152
 
            raise errors.IncompatibleFormat(self, a_bzrdir._format)
153
 
        utf8_files = [('revision-history', ''),
154
 
                      ('branch-name', ''),
 
148
            raise errors.IncompatibleFormat(self, a_controldir._format)
 
149
        utf8_files = [('revision-history', b''),
 
150
                      ('branch-name', b''),
155
151
                      ]
156
 
        mutter('creating branch %r in %s', self, a_bzrdir.user_url)
157
 
        branch_transport = a_bzrdir.get_branch_transport(self, name=name)
 
152
        mutter('creating branch %r in %s', self, a_controldir.user_url)
 
153
        branch_transport = a_controldir.get_branch_transport(self, name=name)
158
154
        control_files = lockable_files.LockableFiles(branch_transport,
159
 
            'branch-lock', lockable_files.TransportLock)
 
155
                                                     'branch-lock', lockable_files.TransportLock)
160
156
        control_files.create_lock()
161
157
        try:
162
158
            control_files.lock_write()
168
164
            for (filename, content) in utf8_files:
169
165
                branch_transport.put_bytes(
170
166
                    filename, content,
171
 
                    mode=a_bzrdir._get_file_mode())
 
167
                    mode=a_controldir._get_file_mode())
172
168
        finally:
173
169
            if lock_taken:
174
170
                control_files.unlock()
175
 
        branch = self.open(a_bzrdir, name, _found=True,
176
 
                found_repository=None)
177
 
        self._run_post_branch_init_hooks(a_bzrdir, name, branch)
 
171
        branch = self.open(a_controldir, name, _found=True,
 
172
                           found_repository=None)
 
173
        self._run_post_branch_init_hooks(a_controldir, name, branch)
178
174
        return branch
179
175
 
180
176
    def __init__(self):
181
177
        super(BzrBranchFormat4, self).__init__()
182
 
        from bzrlib.plugins.weave_fmt.bzrdir import (
 
178
        from .bzrdir import (
183
179
            BzrDirFormat4, BzrDirFormat5, BzrDirFormat6,
184
180
            )
185
 
        self._matchingbzrdir = BzrDirFormat6()
 
181
        self._matchingcontroldir = BzrDirFormat6()
186
182
        self._compatible_bzrdirs = [BzrDirFormat4, BzrDirFormat5,
187
 
            BzrDirFormat6]
 
183
                                    BzrDirFormat6]
188
184
 
189
185
    def network_name(self):
190
186
        """The network name for this format is the control dirs disk label."""
191
 
        return self._matchingbzrdir.get_format_string()
 
187
        return self._matchingcontroldir.get_format_string()
192
188
 
193
189
    def get_format_description(self):
194
190
        return "Branch format 4"
195
191
 
196
 
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
197
 
            found_repository=None, possible_transports=None):
 
192
    def open(self, a_controldir, name=None, _found=False, ignore_fallbacks=False,
 
193
             found_repository=None, possible_transports=None):
198
194
        """See BranchFormat.open()."""
199
195
        if name is None:
200
 
            name = a_bzrdir._get_selected_branch()
 
196
            name = a_controldir._get_selected_branch()
201
197
        if name != "":
202
198
            raise errors.NoColocatedBranchSupport(self)
203
199
        if not _found:
204
200
            # we are being called directly and must probe.
205
201
            raise NotImplementedError
206
202
        if found_repository is None:
207
 
            found_repository = a_bzrdir.open_repository()
 
203
            found_repository = a_controldir.open_repository()
208
204
        return BzrBranch4(_format=self,
209
 
                         _control_files=a_bzrdir._control_files,
210
 
                         a_bzrdir=a_bzrdir,
211
 
                         name=name,
212
 
                         _repository=found_repository,
213
 
                         possible_transports=possible_transports)
 
205
                          _control_files=a_controldir._control_files,
 
206
                          a_controldir=a_controldir,
 
207
                          name=name,
 
208
                          _repository=found_repository,
 
209
                          possible_transports=possible_transports)
214
210
 
215
211
    def __str__(self):
216
212
        return "Bazaar-NG branch format 4"
217
213
 
218
214
    def supports_leaving_lock(self):
219
215
        return False
 
216
 
 
217
    supports_reference_locations = False