/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: Martin Pool
  • Date: 2007-08-20 05:53:39 UTC
  • mfrom: (2727 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2730.
  • Revision ID: mbp@sourcefrog.net-20070820055339-uzei7f7i7jo6tugg
merge trunk

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