/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/branchbuilder.py

  • Committer: John Arbash Meinel
  • Date: 2009-04-21 23:54:16 UTC
  • mto: (4300.1.7 groupcompress_info)
  • mto: This revision was merged to the branch mainline in revision 4301.
  • Revision ID: john@arbash-meinel.com-20090421235416-f0cz6ilf5cufbugi
Fix bug #364900, properly remove the 64kB that was just encoded in the copy.
Also, stop supporting None as a copy length in 'encode_copy_instruction'.
It was only used by the test suite, and it is good to pull that sort of thing out of
production code. (Besides, setting the copy to 64kB has the same effect.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
        finally:
104
104
            tree.unlock()
105
105
 
106
 
    def _do_commit(self, tree, message=None, message_callback=None, **kwargs):
 
106
    def _do_commit(self, tree, message=None, **kwargs):
107
107
        reporter = commit.NullCommitReporter()
108
 
        if message is None and message_callback is None:
 
108
        if message is None:
109
109
            message = u'commit %d' % (self._branch.revno() + 1,)
110
 
        return tree.commit(message, message_callback=message_callback,
 
110
        return tree.commit(message,
111
111
            reporter=reporter,
112
112
            **kwargs)
113
113
 
114
 
    def _move_branch_pointer(self, new_revision_id,
115
 
        allow_leftmost_as_ghost=False):
 
114
    def _move_branch_pointer(self, new_revision_id):
116
115
        """Point self._branch to a different revision id."""
117
116
        self._branch.lock_write()
118
117
        try:
119
118
            # We don't seem to have a simple set_last_revision(), so we
120
119
            # implement it here.
121
120
            cur_revno, cur_revision_id = self._branch.last_revision_info()
122
 
            try:
123
 
                g = self._branch.repository.get_graph()
124
 
                new_revno = g.find_distance_to_null(new_revision_id,
125
 
                    [(cur_revision_id, cur_revno)])
126
 
                self._branch.set_last_revision_info(new_revno, new_revision_id)
127
 
            except errors.GhostRevisionsHaveNoRevno:
128
 
                if not allow_leftmost_as_ghost:
129
 
                    raise
130
 
                new_revno = 1
 
121
            g = self._branch.repository.get_graph()
 
122
            new_revno = g.find_distance_to_null(new_revision_id,
 
123
                                                [(cur_revision_id, cur_revno)])
 
124
            self._branch.set_last_revision_info(new_revno, new_revision_id)
131
125
        finally:
132
126
            self._branch.unlock()
133
127
        if self._tree is not None:
161
155
        self._tree = None
162
156
 
163
157
    def build_snapshot(self, revision_id, parent_ids, actions,
164
 
        message=None, timestamp=None, allow_leftmost_as_ghost=False,
165
 
        committer=None, timezone=None, message_callback=None):
 
158
                       message=None, timestamp=None):
166
159
        """Build a commit, shaped in a specific way.
167
160
 
168
161
        :param revision_id: The handle for the new commit, can be None
175
168
            ('rename', ('orig-path', 'new-path'))
176
169
        :param message: An optional commit message, if not supplied, a default
177
170
            commit message will be written.
178
 
        :param message_callback: A message callback to use for the commit, as
179
 
            per mutabletree.commit.
180
171
        :param timestamp: If non-None, set the timestamp of the commit to this
181
172
            value.
182
 
        :param timezone: An optional timezone for timestamp.
183
 
        :param committer: An optional username to use for commit
184
 
        :param allow_leftmost_as_ghost: True if the leftmost parent should be
185
 
            permitted to be a ghost.
186
173
        :return: The revision_id of the new commit
187
174
        """
188
175
        if parent_ids is not None:
189
176
            base_id = parent_ids[0]
190
177
            if base_id != self._branch.last_revision():
191
 
                self._move_branch_pointer(base_id,
192
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
 
178
                self._move_branch_pointer(base_id)
193
179
 
194
180
        if self._tree is not None:
195
181
            tree = self._tree
198
184
        tree.lock_write()
199
185
        try:
200
186
            if parent_ids is not None:
201
 
                tree.set_parent_ids(parent_ids,
202
 
                    allow_leftmost_as_ghost=allow_leftmost_as_ghost)
 
187
                tree.set_parent_ids(parent_ids)
203
188
            # Unfortunately, MemoryTree.add(directory) just creates an
204
189
            # inventory entry. And the only public function to create a
205
190
            # directory is MemoryTree.mkdir() which creates the directory, but
246
231
            for file_id, content in new_contents.iteritems():
247
232
                tree.put_file_bytes_non_atomic(file_id, content)
248
233
            return self._do_commit(tree, message=message, rev_id=revision_id,
249
 
                timestamp=timestamp, timezone=timezone, committer=committer,
250
 
                message_callback=message_callback)
 
234
                timestamp=timestamp)
251
235
        finally:
252
236
            tree.unlock()
253
237