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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-15 20:13:37 UTC
  • mfrom: (4526.8.7 commit-transform)
  • Revision ID: pqm@pqm.ubuntu.com-20090715201337-pujob8s96drd11p3
Implement commit for tree transforms (abentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
442
442
        conflicts.extend(self._overwrite_conflicts())
443
443
        return conflicts
444
444
 
 
445
    def _check_malformed(self):
 
446
        conflicts = self.find_conflicts()
 
447
        if len(conflicts) != 0:
 
448
            raise MalformedTransform(conflicts=conflicts)
 
449
 
445
450
    def _add_tree_children(self):
446
451
        """Add all the children of all active parents to the known paths.
447
452
 
859
864
        """
860
865
        return _PreviewTree(self)
861
866
 
 
867
    def commit(self, branch, message, merge_parents=None, strict=False):
 
868
        """Commit the result of this TreeTransform to a branch.
 
869
 
 
870
        :param branch: The branch to commit to.
 
871
        :param message: The message to attach to the commit.
 
872
        :param merge_parents: Additional parents specified by pending merges.
 
873
        :return: The revision_id of the revision committed.
 
874
        """
 
875
        self._check_malformed()
 
876
        if strict:
 
877
            unversioned = set(self._new_contents).difference(set(self._new_id))
 
878
            for trans_id in unversioned:
 
879
                if self.final_file_id(trans_id) is None:
 
880
                    raise errors.StrictCommitFailed()
 
881
 
 
882
        revno, last_rev_id = branch.last_revision_info()
 
883
        if last_rev_id == _mod_revision.NULL_REVISION:
 
884
            if merge_parents is not None:
 
885
                raise ValueError('Cannot supply merge parents for first'
 
886
                                 ' commit.')
 
887
            parent_ids = []
 
888
        else:
 
889
            parent_ids = [last_rev_id]
 
890
            if merge_parents is not None:
 
891
                parent_ids.extend(merge_parents)
 
892
        if self._tree.get_revision_id() != last_rev_id:
 
893
            raise ValueError('TreeTransform not based on branch basis: %s' %
 
894
                             self._tree.get_revision_id())
 
895
        builder = branch.get_commit_builder(parent_ids)
 
896
        preview = self.get_preview_tree()
 
897
        list(builder.record_iter_changes(preview, last_rev_id,
 
898
                                         self.iter_changes()))
 
899
        builder.finish_inventory()
 
900
        revision_id = builder.commit(message)
 
901
        branch.set_last_revision_info(revno + 1, revision_id)
 
902
        return revision_id
 
903
 
862
904
    def _text_parent(self, trans_id):
863
905
        file_id = self.tree_file_id(trans_id)
864
906
        try:
1354
1396
                continue
1355
1397
            yield self.trans_id_tree_path(childpath)
1356
1398
 
1357
 
 
1358
1399
    def apply(self, no_conflicts=False, precomputed_delta=None, _mover=None):
1359
1400
        """Apply all changes to the inventory and filesystem.
1360
1401
 
1370
1411
        :param _mover: Supply an alternate FileMover, for testing
1371
1412
        """
1372
1413
        if not no_conflicts:
1373
 
            conflicts = self.find_conflicts()
1374
 
            if len(conflicts) != 0:
1375
 
                raise MalformedTransform(conflicts=conflicts)
 
1414
            self._check_malformed()
1376
1415
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1377
1416
        try:
1378
1417
            if precomputed_delta is None: