~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

Deprecate compare_trees and move its body to InterTree.changes_from.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib.inventory import InventoryEntry
18
18
from bzrlib.trace import mutter
19
 
from bzrlib import tree
 
19
from bzrlib.symbol_versioning import deprecated_function, zero_ten
20
20
 
21
21
 
22
22
class TreeDelta(object):
143
143
            show_list(self.unchanged)
144
144
 
145
145
 
 
146
@deprecated_function(zero_ten)
146
147
def compare_trees(old_tree, new_tree, want_unchanged=False,
147
148
                  specific_files=None, extra_trees=None,
148
149
                  require_versioned=False):
149
 
    """Describe changes from one tree to another.
150
 
 
151
 
    Returns a TreeDelta with details of added, modified, renamed, and
152
 
    deleted entries.
153
 
 
154
 
    The root entry is specifically exempt.
155
 
 
156
 
    This only considers versioned files.
157
 
 
158
 
    want_unchanged
159
 
        If true, also list files unchanged from one version to
160
 
        the next.
161
 
 
162
 
    specific_files
163
 
        If supplied, only check for changes to specified names or
164
 
        files within them.  When mapping filenames to ids, all matches in all
165
 
        trees (including optional extra_trees) are used, and all children of
166
 
        matched directories are included.
167
 
 
168
 
    extra_trees
169
 
        If non-None, a list of more trees to use for looking up file_ids from
170
 
        paths
171
 
 
172
 
    require_versioned
173
 
        If true, an all files are required to be versioned, and
174
 
        PathsNotVersionedError will be thrown if they are not.
175
 
    """
176
 
    # NB: show_status depends on being able to pass in non-versioned files and
177
 
    # report them as unknown
178
 
    old_tree.lock_read()
179
 
    try:
180
 
        new_tree.lock_read()
181
 
        try:
182
 
            trees = (new_tree, old_tree)
183
 
            if extra_trees is not None:
184
 
                trees = trees + tuple(extra_trees)
185
 
            specific_file_ids = tree.find_ids_across_trees(specific_files, 
186
 
                trees, require_versioned=require_versioned)
187
 
            if specific_files and not specific_file_ids:
188
 
                # All files are unversioned, so just return an empty delta
189
 
                # _compare_trees would think we want a complete delta
190
 
                return TreeDelta()
191
 
            return _compare_trees(old_tree, new_tree, want_unchanged,
192
 
                                  specific_file_ids)
193
 
        finally:
194
 
            new_tree.unlock()
195
 
    finally:
196
 
        old_tree.unlock()
 
150
    """compare_trees was deprecated in 0.10. Please see Tree.changes_from."""
 
151
    return new_tree.changes_from(old_tree,
 
152
        want_unchanged=want_unchanged,
 
153
        specific_files=specific_files,
 
154
        extra_trees=extra_trees,
 
155
        require_versioned=require_versioned)
197
156
 
198
157
 
199
158
def _compare_trees(old_tree, new_tree, want_unchanged, specific_file_ids):