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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

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