~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2006-02-22 14:39:42 UTC
  • mto: (2027.1.2 revert-subpath-56549)
  • mto: This revision was merged to the branch mainline in revision 1570.
  • Revision ID: abentley@panoramicfeedback.com-20060222143942-ae72299f2de66767
Fixed build_tree with symlinks

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
                            sha_string, sha_strings, sha_file, isdir, isfile,
80
80
                            split_lines)
81
81
import bzrlib.config
 
82
import bzrlib.errors as errors
82
83
from bzrlib.errors import (BzrError, PointlessCommit,
83
84
                           HistoryMissing,
84
85
                           ConflictsInTree,
90
91
from bzrlib.trace import mutter, note, warning
91
92
from bzrlib.xml5 import serializer_v5
92
93
from bzrlib.inventory import Inventory, ROOT_ID
 
94
from bzrlib.symbol_versioning import *
93
95
from bzrlib.weave import Weave
94
96
from bzrlib.weavefile import read_weave, write_weave_v5
95
97
from bzrlib.workingtree import WorkingTree
96
98
 
97
99
 
 
100
@deprecated_function(zero_seven)
98
101
def commit(*args, **kwargs):
99
102
    """Commit a new revision to a branch.
100
103
 
168
171
            self.config = None
169
172
        
170
173
    def commit(self,
171
 
               branch, message,
 
174
               branch=DEPRECATED_PARAMETER, message=None,
172
175
               timestamp=None,
173
176
               timezone=None,
174
177
               committer=None,
177
180
               allow_pointless=True,
178
181
               strict=False,
179
182
               verbose=False,
180
 
               revprops=None):
 
183
               revprops=None,
 
184
               working_tree=None):
181
185
        """Commit working copy as a new revision.
182
186
 
 
187
        branch -- the deprecated branch to commit to. New callers should pass in 
 
188
                  working_tree instead
 
189
 
 
190
        message -- the commit message, a mandatory parameter
 
191
 
183
192
        timestamp -- if not None, seconds-since-epoch for a
184
193
             postdated/predated commit.
185
194
 
201
210
        """
202
211
        mutter('preparing to commit')
203
212
 
204
 
        self.branch = branch
205
 
        self.weave_store = branch.weave_store
 
213
        if deprecated_passed(branch):
 
214
            warn("Commit.commit (branch, ...): The branch parameter is "
 
215
                 "deprecated as of bzr 0.8. Please use working_tree= instead.",
 
216
                 DeprecationWarning, stacklevel=2)
 
217
            self.branch = branch
 
218
            self.work_tree = self.branch.bzrdir.open_workingtree()
 
219
        elif working_tree is None:
 
220
            raise BzrError("One of branch and working_tree must be passed into commit().")
 
221
        else:
 
222
            self.work_tree = working_tree
 
223
            self.branch = self.work_tree.branch
 
224
        if message is None:
 
225
            raise BzrError("The message keyword parameter is required for commit().")
 
226
 
 
227
        self.weave_store = self.branch.repository.weave_store
206
228
        self.rev_id = rev_id
207
229
        self.specific_files = specific_files
208
230
        self.allow_pointless = allow_pointless
209
 
        self.revprops = {'branch-nick': branch.nick}
 
231
        self.revprops = {'branch-nick': self.branch.nick}
210
232
        if revprops:
211
233
            self.revprops.update(revprops)
212
 
        self.work_tree = WorkingTree(branch.base, branch)
 
234
 
 
235
        # check for out of date working trees
 
236
        if self.work_tree.last_revision() != self.branch.last_revision():
 
237
            raise errors.OutOfDateTree(self.work_tree)
213
238
 
214
239
        if strict:
215
240
            # raise an exception as soon as we find a single unknown.
249
274
        self.branch.lock_write()
250
275
        try:
251
276
            self.work_inv = self.work_tree.inventory
252
 
            self.basis_tree = self.branch.basis_tree()
 
277
            self.basis_tree = self.work_tree.basis_tree()
253
278
            self.basis_inv = self.basis_tree.inventory
254
279
 
255
280
            self._gather_parents()
274
299
            self._make_revision()
275
300
            self.work_tree.set_pending_merges([])
276
301
            self.branch.append_revision(self.rev_id)
 
302
            if len(self.parents):
 
303
                precursor = self.parents[0]
 
304
            else:
 
305
                precursor = None
 
306
            self.work_tree.set_last_revision(self.rev_id, precursor)
277
307
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
278
308
            if self.config.post_commit() is not None:
279
309
                hooks = self.config.post_commit().split(' ')
290
320
        """Store the inventory for the new revision."""
291
321
        inv_text = serializer_v5.write_inventory_to_string(self.new_inv)
292
322
        self.inv_sha1 = sha_string(inv_text)
293
 
        s = self.branch.control_weaves
 
323
        s = self.branch.repository.control_weaves
294
324
        s.add_text('inventory', self.rev_id,
295
325
                   split_lines(inv_text), self.present_parents,
296
326
                   self.branch.get_transaction())
319
349
            self.parents.append(precursor_id)
320
350
        self.parents += pending_merges
321
351
        for revision in self.parents:
322
 
            if self.branch.has_revision(revision):
323
 
                self.parent_invs.append(self.branch.get_inventory(revision))
 
352
            if self.branch.repository.has_revision(revision):
 
353
                inventory = self.branch.repository.get_inventory(revision)
 
354
                self.parent_invs.append(inventory)
324
355
                self.present_parents.append(revision)
325
356
 
326
357
    def _check_parents_present(self):
327
358
        for parent_id in self.parents:
328
359
            mutter('commit parent revision {%s}', parent_id)
329
 
            if not self.branch.has_revision(parent_id):
 
360
            if not self.branch.repository.has_revision(parent_id):
330
361
                if parent_id == self.branch.last_revision():
331
362
                    warning("parent is missing %r", parent_id)
332
363
                    raise HistoryMissing(self.branch, 'revision', parent_id)
348
379
        rev_tmp.seek(0)
349
380
        if self.config.signature_needed():
350
381
            plaintext = Testament(self.rev, self.new_inv).as_short_text()
351
 
            self.branch.store_revision_signature(gpg.GPGStrategy(self.config),
352
 
                                                 plaintext, self.rev_id)
353
 
        self.branch.revision_store.add(rev_tmp, self.rev_id)
 
382
            self.branch.repository.store_revision_signature(
 
383
                gpg.GPGStrategy(self.config), plaintext, self.rev_id)
 
384
        self.branch.repository.revision_store.add(rev_tmp, self.rev_id)
354
385
        mutter('new revision_id is {%s}', self.rev_id)
355
386
 
356
387
    def _remove_deleted(self):