~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-07-25 19:32:22 UTC
  • mto: (1551.19.24 Aaron's mergeable stuff)
  • mto: This revision was merged to the branch mainline in revision 2664.
  • Revision ID: abentley@panoramicfeedback.com-20070725193222-lcq4z4980ffd4bf5
Stop using _merge_helper for merging

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
from bzrlib.osutils import (file_kind, supports_executable, pathjoin, lexists,
35
35
                            delete_any)
36
36
from bzrlib.progress import DummyProgress, ProgressPhase
37
 
from bzrlib.symbol_versioning import deprecated_function, zero_fifteen
 
37
from bzrlib.symbol_versioning import deprecated_function, zero_fifteen, \
 
38
        zero_nineteen
38
39
from bzrlib.trace import mutter, warning
39
40
from bzrlib import tree
40
41
import bzrlib.ui
717
718
    def _duplicate_entries(self, by_parent):
718
719
        """No directory may have two entries with the same name."""
719
720
        conflicts = []
 
721
        if (self._new_name, self._new_parent) == ({}, {}):
 
722
            return conflicts
720
723
        for children in by_parent.itervalues():
721
724
            name_ids = [(self.final_name(t), t) for t in children]
722
725
            name_ids.sort()
783
786
            return True
784
787
        return False
785
788
            
786
 
    def apply(self):
 
789
    def apply(self, no_conflicts=False):
787
790
        """Apply all changes to the inventory and filesystem.
788
791
        
789
792
        If filesystem or inventory conflicts are present, MalformedTransform
790
793
        will be thrown.
791
794
 
792
795
        If apply succeeds, finalize is not necessary.
 
796
 
 
797
        :param no_conflicts: if True, the caller guarantees there are no
 
798
            conflicts, so no check is made.
793
799
        """
794
 
        conflicts = self.find_conflicts()
795
 
        if len(conflicts) != 0:
796
 
            raise MalformedTransform(conflicts=conflicts)
 
800
        if not no_conflicts:
 
801
            conflicts = self.find_conflicts()
 
802
            if len(conflicts) != 0:
 
803
                raise MalformedTransform(conflicts=conflicts)
797
804
        inv = self._tree.inventory
798
805
        inventory_delta = []
799
806
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1418
1425
        working_tree.unlock()
1419
1426
 
1420
1427
 
 
1428
@deprecated_function(zero_nineteen)
1421
1429
def change_entry(tt, file_id, working_tree, target_tree, 
1422
1430
                 trans_id_file_id, backups, trans_id, by_parent):
1423
1431
    """Replace a file_id's contents with those from a target tree."""
 
1432
    if file_id is None and target_tree is None:
 
1433
        # skip the logic altogether in the deprecation test
 
1434
        return
1424
1435
    e_trans_id = trans_id_file_id(file_id)
1425
1436
    entry = target_tree.inventory[file_id]
1426
1437
    has_contents, contents_mod, meta_mod, = _entry_changes(file_id, entry, 
1645
1656
        pb.clear()
1646
1657
 
1647
1658
 
1648
 
def conflict_pass(tt, conflicts):
1649
 
    """Resolve some classes of conflicts."""
 
1659
def conflict_pass(tt, conflicts, path_tree=None):
 
1660
    """Resolve some classes of conflicts.
 
1661
 
 
1662
    :param tt: The transform to resolve conflicts in
 
1663
    :param conflicts: The conflicts to resolve
 
1664
    :param path_tree: A Tree to get supplemental paths from
 
1665
    """
1650
1666
    new_conflicts = set()
1651
1667
    for c_type, conflict in ((c[0], c) for c in conflicts):
1652
1668
        if c_type == 'duplicate id':
1683
1699
            except KeyError:
1684
1700
                tt.create_directory(trans_id)
1685
1701
                new_conflicts.add((c_type, 'Created directory', trans_id))
 
1702
                try:
 
1703
                    tt.final_name(trans_id)
 
1704
                except NoFinalPath:
 
1705
                    file_id = tt.final_file_id(trans_id)
 
1706
                    entry = path_tree.inventory[file_id]
 
1707
                    parent_trans_id = tt.trans_id_file_id(entry.parent_id)
 
1708
                    tt.adjust_path(entry.name, parent_trans_id, trans_id)
1686
1709
        elif c_type == 'unversioned parent':
1687
1710
            tt.version_file(tt.inactive_file_id(conflict[1]), conflict[1])
1688
1711
            new_conflicts.add((c_type, 'Versioned directory', conflict[1]))