~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

Switch to PathsNotVersioned, accept extra_trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
277
277
 
278
278
def show_diff_trees(old_tree, new_tree, to_file, specific_files=None,
279
279
                    external_diff_options=None,
280
 
                    old_label='a/', new_label='b/'):
 
280
                    old_label='a/', new_label='b/',
 
281
                    extra_trees=None):
281
282
    """Show in text form the changes from one tree to another.
282
283
 
283
284
    to_files
292
293
        try:
293
294
            return _show_diff_trees(old_tree, new_tree, to_file,
294
295
                                    specific_files, external_diff_options,
295
 
                                    old_label=old_label, new_label=new_label)
 
296
                                    old_label=old_label, new_label=new_label,
 
297
                                    extra_trees=extra_trees)
296
298
        finally:
297
299
            new_tree.unlock()
298
300
    finally:
301
303
 
302
304
def _show_diff_trees(old_tree, new_tree, to_file,
303
305
                     specific_files, external_diff_options, 
304
 
                     old_label='a/', new_label='b/' ):
 
306
                     old_label='a/', new_label='b/', extra_trees=None):
305
307
 
306
308
    # GNU Patch uses the epoch date to detect files that are being added
307
309
    # or removed in a diff.
310
312
    # TODO: Generation of pseudo-diffs for added/deleted files could
311
313
    # be usefully made into a much faster special case.
312
314
 
313
 
    _raise_if_doubly_unversioned(specific_files, old_tree, new_tree)
314
 
 
315
315
    if external_diff_options:
316
316
        assert isinstance(external_diff_options, basestring)
317
317
        opts = external_diff_options.split()
321
321
        diff_file = internal_diff
322
322
    
323
323
    delta = compare_trees(old_tree, new_tree, want_unchanged=False,
324
 
                          specific_files=specific_files)
 
324
                          specific_files=specific_files, 
 
325
                          require_versioned=True, extra_trees=extra_trees)
325
326
 
326
327
    has_changes = 0
327
328
    for path, file_id, kind in delta.removed:
379
380
    return time.strftime('%Y-%m-%d %H:%M:%S +0000', tm)
380
381
 
381
382
 
382
 
def _raise_if_doubly_unversioned(specific_files, old_tree, new_tree):
383
 
    """Complain if paths are not versioned in either tree."""
384
 
    if not specific_files:
385
 
        return
386
 
    old_unversioned = old_tree.filter_unversioned_files(specific_files)
387
 
    new_unversioned = new_tree.filter_unversioned_files(specific_files)
388
 
    unversioned = old_unversioned.intersection(new_unversioned)
389
 
    if unversioned:
390
 
        raise errors.PathsNotVersionedError(sorted(unversioned))
391
 
    
392
 
 
393
383
def _raise_if_nonexistent(paths, old_tree, new_tree):
394
384
    """Complain if paths are not in either inventory or tree.
395
385