~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    multiparent,
32
32
    osutils,
33
33
    revision as _mod_revision,
 
34
    ui,
34
35
    )
35
36
""")
36
37
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
49
50
    splitpath,
50
51
    supports_executable,
51
52
)
52
 
from bzrlib.progress import DummyProgress, ProgressPhase
 
53
from bzrlib.progress import ProgressPhase
53
54
from bzrlib.symbol_versioning import (
54
55
        deprecated_function,
55
56
        deprecated_in,
79
80
class TreeTransformBase(object):
80
81
    """The base class for TreeTransform and its kin."""
81
82
 
82
 
    def __init__(self, tree, pb=DummyProgress(),
 
83
    def __init__(self, tree, pb=None,
83
84
                 case_sensitive=True):
84
85
        """Constructor.
85
86
 
86
87
        :param tree: The tree that will be transformed, but not necessarily
87
88
            the output tree.
88
 
        :param pb: A ProgressTask indicating how much progress is being made
 
89
        :param pb: ignored
89
90
        :param case_sensitive: If True, the target of the transform is
90
91
            case sensitive, not just case preserving.
91
92
        """
1062
1063
class DiskTreeTransform(TreeTransformBase):
1063
1064
    """Tree transform storing its contents on disk."""
1064
1065
 
1065
 
    def __init__(self, tree, limbodir, pb=DummyProgress(),
 
1066
    def __init__(self, tree, limbodir, pb=None,
1066
1067
                 case_sensitive=True):
1067
1068
        """Constructor.
1068
1069
        :param tree: The tree that will be transformed, but not necessarily
1069
1070
            the output tree.
1070
1071
        :param limbodir: A directory where new files can be stored until
1071
1072
            they are installed in their proper places
1072
 
        :param pb: A ProgressBar indicating how much progress is being made
 
1073
        :param pb: ignored
1073
1074
        :param case_sensitive: If True, the target of the transform is
1074
1075
            case sensitive, not just case preserving.
1075
1076
        """
1339
1340
    FileMover does not delete files until it is sure that a rollback will not
1340
1341
    happen.
1341
1342
    """
1342
 
    def __init__(self, tree, pb=DummyProgress()):
 
1343
    def __init__(self, tree, pb=None):
1343
1344
        """Note: a tree_write lock is taken on the tree.
1344
1345
 
1345
1346
        Use TreeTransform.finalize() to release the lock (can be omitted if
1691
1692
    unversioned files in the input tree.
1692
1693
    """
1693
1694
 
1694
 
    def __init__(self, tree, pb=DummyProgress(), case_sensitive=True):
 
1695
    def __init__(self, tree, pb=None, case_sensitive=True):
1695
1696
        tree.lock_read()
1696
1697
        limbodir = osutils.mkdtemp(prefix='bzr-limbo-')
1697
1698
        DiskTreeTransform.__init__(self, tree, limbodir, pb, case_sensitive)
2589
2590
 
2590
2591
 
2591
2592
def revert(working_tree, target_tree, filenames, backups=False,
2592
 
           pb=DummyProgress(), change_reporter=None):
 
2593
           pb=None, change_reporter=None):
2593
2594
    """Revert a working tree's contents to those of a target tree."""
2594
2595
    target_tree.lock_read()
 
2596
    pb = ui.ui_factory.nested_progress_bar()
2595
2597
    tt = TreeTransform(working_tree, pb)
2596
2598
    try:
2597
2599
        pp = ProgressPhase("Revert phase", 3, pb)
2616
2618
def _prepare_revert_transform(working_tree, target_tree, tt, filenames,
2617
2619
                              backups, pp, basis_tree=None,
2618
2620
                              merge_modified=None):
2619
 
    pp.next_phase()
2620
2621
    child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
2621
2622
    try:
2622
2623
        if merge_modified is None:
2626
2627
                                      merge_modified, basis_tree)
2627
2628
    finally:
2628
2629
        child_pb.finished()
2629
 
    pp.next_phase()
2630
2630
    child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
2631
2631
    try:
2632
2632
        raw_conflicts = resolve_conflicts(tt, child_pb,
2754
2754
    return merge_modified
2755
2755
 
2756
2756
 
2757
 
def resolve_conflicts(tt, pb=DummyProgress(), pass_func=None):
 
2757
def resolve_conflicts(tt, pb=None, pass_func=None):
2758
2758
    """Make many conflict-resolution attempts, but die if they fail"""
2759
2759
    if pass_func is None:
2760
2760
        pass_func = conflict_pass
2761
2761
    new_conflicts = set()
 
2762
    pb = ui.ui_factory.nested_progress_bar()
2762
2763
    try:
2763
2764
        for n in range(10):
2764
2765
            pb.update('Resolution pass', n+1, 10)
2768
2769
            new_conflicts.update(pass_func(tt, conflicts))
2769
2770
        raise MalformedTransform(conflicts=conflicts)
2770
2771
    finally:
2771
 
        pb.clear()
 
2772
        pb.finished()
2772
2773
 
2773
2774
 
2774
2775
def conflict_pass(tt, conflicts, path_tree=None):
2823
2824
                        # special-case the other tree root (move its
2824
2825
                        # children to current root)
2825
2826
                        if entry.parent_id is None:
2826
 
                            create=False
 
2827
                            create = False
2827
2828
                            moved = _reparent_transform_children(
2828
2829
                                tt, trans_id, tt.root)
2829
2830
                            for child in moved: