/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/branchfmt/fullhistory.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
"""Full history branch formats."""
18
18
 
19
 
from .. import (
 
19
from __future__ import absolute_import
 
20
 
 
21
from brzlib import (
20
22
    debug,
21
23
    errors,
22
24
    revision as _mod_revision,
23
25
    )
24
26
 
25
 
from ..branch import (
 
27
from brzlib.branch import (
26
28
    Branch,
27
 
    )
28
 
from .branch import (
 
29
    BranchFormatMetadir,
29
30
    BzrBranch,
30
 
    BranchFormatMetadir,
31
31
    )
32
32
 
33
 
from ..trace import mutter_callsite
 
33
from brzlib.decorators import (
 
34
    needs_write_lock,
 
35
    )
 
36
from brzlib.trace import mutter_callsite
34
37
 
35
38
 
36
39
class FullHistoryBzrBranch(BzrBranch):
37
40
    """Bzr branch which contains the full revision history."""
38
41
 
 
42
    @needs_write_lock
39
43
    def set_last_revision_info(self, revno, revision_id):
40
 
        if not revision_id or not isinstance(revision_id, bytes):
41
 
            raise errors.InvalidRevisionId(
42
 
                revision_id=revision_id, branch=self)
 
44
        if not revision_id or not isinstance(revision_id, basestring):
 
45
            raise errors.InvalidRevisionId(revision_id=revision_id, branch=self)
43
46
        revision_id = _mod_revision.ensure_null(revision_id)
44
 
        with self.lock_write():
45
 
            # this old format stores the full history, but this api doesn't
46
 
            # provide it, so we must generate, and might as well check it's
47
 
            # correct
48
 
            history = self._lefthand_history(revision_id)
49
 
            if len(history) != revno:
50
 
                raise AssertionError('%d != %d' % (len(history), revno))
51
 
            self._set_revision_history(history)
 
47
        # this old format stores the full history, but this api doesn't
 
48
        # provide it, so we must generate, and might as well check it's
 
49
        # correct
 
50
        history = self._lefthand_history(revision_id)
 
51
        if len(history) != revno:
 
52
            raise AssertionError('%d != %d' % (len(history), revno))
 
53
        self._set_revision_history(history)
52
54
 
53
55
    def _read_last_revision_info(self):
54
56
        rh = self._revision_history()
85
87
        This performs the actual writing to disk.
86
88
        It is intended to be called by set_revision_history."""
87
89
        self._transport.put_bytes(
88
 
            'revision-history', b'\n'.join(history),
89
 
            mode=self.controldir._get_file_mode())
 
90
            'revision-history', '\n'.join(history),
 
91
            mode=self.bzrdir._get_file_mode())
90
92
 
91
93
    def _gen_revision_history(self):
92
 
        history = self._transport.get_bytes('revision-history').split(b'\n')
93
 
        if history[-1:] == [b'']:
 
94
        history = self._transport.get_bytes('revision-history').split('\n')
 
95
        if history[-1:] == ['']:
94
96
            # There shouldn't be a trailing newline, but just in case.
95
97
            history.pop()
96
98
        return history
112
114
                new_history = rev.get_history(self.repository)[1:]
113
115
        destination._set_revision_history(new_history)
114
116
 
 
117
    @needs_write_lock
115
118
    def generate_revision_history(self, revision_id, last_rev=None,
116
 
                                  other_branch=None):
 
119
        other_branch=None):
117
120
        """Create a new revision history that will finish with revision_id.
118
121
 
119
122
        :param revision_id: the new tip to use.
122
125
        :param other_branch: The other branch that DivergedBranches should
123
126
            raise with respect to.
124
127
        """
125
 
        with self.lock_write():
126
 
            self._set_revision_history(self._lefthand_history(revision_id,
127
 
                                                              last_rev, other_branch))
 
128
        self._set_revision_history(self._lefthand_history(revision_id,
 
129
            last_rev, other_branch))
128
130
 
129
131
 
130
132
class BzrBranch5(FullHistoryBzrBranch):
153
155
    @classmethod
154
156
    def get_format_string(cls):
155
157
        """See BranchFormat.get_format_string()."""
156
 
        return b"Bazaar-NG branch format 5\n"
 
158
        return "Bazaar-NG branch format 5\n"
157
159
 
158
160
    def get_format_description(self):
159
161
        """See BranchFormat.get_format_description()."""
160
162
        return "Branch format 5"
161
163
 
162
 
    def initialize(self, a_controldir, name=None, repository=None,
 
164
    def initialize(self, a_bzrdir, name=None, repository=None,
163
165
                   append_revisions_only=None):
164
 
        """Create a branch of this format in a_controldir."""
 
166
        """Create a branch of this format in a_bzrdir."""
165
167
        if append_revisions_only:
166
 
            raise errors.UpgradeRequired(a_controldir.user_url)
167
 
        utf8_files = [('revision-history', b''),
168
 
                      ('branch-name', b''),
 
168
            raise errors.UpgradeRequired(a_bzrdir.user_url)
 
169
        utf8_files = [('revision-history', ''),
 
170
                      ('branch-name', ''),
169
171
                      ]
170
 
        return self._initialize_helper(a_controldir, utf8_files, name, repository)
 
172
        return self._initialize_helper(a_bzrdir, utf8_files, name, repository)
171
173
 
172
174
    def supports_tags(self):
173
175
        return False
174
176
 
175
 
    supports_reference_locations = False
 
177
 
 
178