~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Vincent Ladeuil
  • Date: 2010-02-05 10:27:33 UTC
  • mto: (5008.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5009.
  • Revision ID: v.ladeuil+lp@free.fr-20100205102733-8wpjnqz6g4nvrbfu
All Conflict action method names start with 'action_' to avoid potential namespace collisions

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