~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

Allow compare_trees to list root

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
 
143
143
 
144
144
 
145
 
def compare_trees(old_tree, new_tree, want_unchanged=False, specific_files=None):
 
145
def compare_trees(old_tree, new_tree, want_unchanged=False, 
 
146
                  specific_files=None, include_root=False):
146
147
    """Describe changes from one tree to another.
147
148
 
148
149
    Returns a TreeDelta with details of added, modified, renamed, and
149
150
    deleted entries.
150
151
 
151
 
    The root entry is specifically exempt.
 
152
    The root entry is specifically exempt, unless include_root is specified.
152
153
 
153
154
    This only considers versioned files.
154
155
 
168
169
        new_tree.lock_read()
169
170
        try:
170
171
            return _compare_trees(old_tree, new_tree, want_unchanged,
171
 
                                  specific_files)
 
172
                                  specific_files, include_root)
172
173
        finally:
173
174
            new_tree.unlock()
174
175
    finally:
175
176
        old_tree.unlock()
176
177
 
177
178
 
178
 
def _compare_trees(old_tree, new_tree, want_unchanged, specific_files):
 
179
def _compare_trees(old_tree, new_tree, want_unchanged, specific_files,
 
180
                   include_root):
179
181
 
180
182
    from osutils import is_inside_any
181
183
    
189
191
    # Perhaps should take a list of file-ids instead?   Need to indicate any
190
192
    # ids or names which were not found in the trees.
191
193
 
192
 
    old_files = old_tree.list_files()
193
 
    new_files = new_tree.list_files()
 
194
    old_files = old_tree.list_files(include_root)
 
195
    new_files = new_tree.list_files(include_root)
194
196
 
195
197
    more_old = True
196
198
    more_new = True
272
274
            # mark it as added
273
275
            assert entry.file_id not in added
274
276
            added[entry.file_id] = path, entry
275
 
 
276
 
    while old_path or new_path:
 
277
    while (old_path is not None or new_path is not None):
277
278
        # list_files() returns files in alphabetical path sorted order
278
279
        if old_path == new_path:
279
280
            if old_file_id == new_file_id: