/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 bzrlib/branchfmt/fullhistory.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

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