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

  • Committer: Aaron Bentley
  • Date: 2009-05-19 09:14:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4374.
  • Revision ID: aaron@aaronbentley.com-20090519091407-u6gnpr6uj9e0rbju
Trivial support for committing PreviewTree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
206
206
               message_callback=None,
207
207
               recursive='down',
208
208
               exclude=None,
209
 
               possible_master_transports=None):
 
209
               possible_master_transports=None,
 
210
               target_branch=None):
210
211
        """Commit working copy as a new revision.
211
212
 
212
213
        :param message: the commit message (it or message_callback is required)
244
245
            raise BzrError("working_tree must be passed into commit().")
245
246
        else:
246
247
            self.work_tree = working_tree
247
 
            self.branch = self.work_tree.branch
 
248
            if target_branch is None:
 
249
                self.branch = self.work_tree.branch
 
250
                update_tree = True
 
251
            else:
 
252
                self.branch = target_branch
 
253
                update_tree = False
248
254
            if getattr(self.work_tree, 'requires_rich_root', lambda: False)():
249
255
                if not self.branch.repository.supports_rich_root():
250
256
                    raise errors.RootNotRich()
284
290
        self.strict = strict
285
291
        self.verbose = verbose
286
292
 
287
 
        self.work_tree.lock_write()
 
293
        self.branch.lock_write()
 
294
        if update_tree:
 
295
            self.work_tree.lock_write()
 
296
        else:
 
297
            self.work_tree.lock_read()
288
298
        self.parents = self.work_tree.get_parent_ids()
289
299
        # We can use record_iter_changes IFF iter_changes is compatible with
290
300
        # the command line parameters, and the repository has fast delta
360
370
                # report the start of the commit
361
371
                self.reporter.started(new_revno, self.rev_id, master_location)
362
372
 
363
 
                self._update_builder_with_changes()
 
373
                self._update_builder_with_changes(update_tree)
364
374
                self._check_pointless()
365
375
 
366
376
                # TODO: Now the new inventory is known, check for conflicts.
400
410
            self.branch.set_last_revision_info(new_revno, self.rev_id)
401
411
 
402
412
            # Make the working tree up to date with the branch
403
 
            self._set_progress_stage("Updating the working tree")
404
 
            self.work_tree.update_basis_by_delta(self.rev_id,
405
 
                 self.builder.get_basis_delta())
 
413
            if update_tree:
 
414
                self._set_progress_stage("Updating the working tree")
 
415
                self.work_tree.update_basis_by_delta(self.rev_id,
 
416
                     self.builder.get_basis_delta())
406
417
            self.reporter.completed(new_revno, self.rev_id)
407
418
            self._process_post_hooks(old_revno, new_revno)
408
419
        finally:
571
582
        cleanups = [self._cleanup_bound_branch,
572
583
                    self.basis_tree.unlock,
573
584
                    self.work_tree.unlock,
 
585
                    self.branch.unlock,
574
586
                    self.pb.finished]
575
587
        found_exception = None
576
588
        for cleanup in cleanups:
629
641
            else:
630
642
                mutter('commit parent ghost revision {%s}', revision)
631
643
 
632
 
    def _update_builder_with_changes(self):
 
644
    def _update_builder_with_changes(self, update_tree):
633
645
        """Update the commit builder with the data about what has changed.
634
646
        """
635
647
        exclude = self.exclude
639
651
        self._check_strict()
640
652
        if self.use_record_iter_changes:
641
653
            iter_changes = self.work_tree.iter_changes(self.basis_tree)
642
 
            iter_changes = self._filter_iter_changes(iter_changes)
 
654
            iter_changes = self._filter_iter_changes(iter_changes, update_tree)
643
655
            for file_id, path, fs_hash in self.builder.record_iter_changes(
644
656
                self.work_tree, self.basis_revid, iter_changes):
645
657
                self.work_tree._observed_sha1(file_id, path, fs_hash)
649
661
            self._record_unselected()
650
662
            self._report_and_accumulate_deletes()
651
663
 
652
 
    def _filter_iter_changes(self, iter_changes):
 
664
    def _filter_iter_changes(self, iter_changes, update_tree):
653
665
        """Process iter_changes.
654
666
 
655
667
        This method reports on the changes in iter_changes to the user, and 
697
709
                            reporter.snapshot_change('modified', new_path)
698
710
            self._next_progress_entry()
699
711
        # Unversion IDs that were found to be deleted
700
 
        self.work_tree.unversion(deleted_ids)
 
712
        if update_tree:
 
713
            self.work_tree.unversion(deleted_ids)
701
714
 
702
715
    def _record_unselected(self):
703
716
        # If specific files are selected, then all un-selected files must be