~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Martin Pool
  • Date: 2006-04-13 05:37:24 UTC
  • mto: This revision was merged to the branch mainline in revision 1662.
  • Revision ID: mbp@sourcefrog.net-20060413053724-8c0053ac31492637
Give an error for bzr diff on an nonexistent file (Malone #3619)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: UTF-8 -*-
 
1
# Copyright (C) 2004, 2005, 2006 Canonical Ltd.
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
from bzrlib.delta import compare_trees
18
18
from bzrlib.errors import BzrError
 
19
import bzrlib.errors as errors
19
20
from bzrlib.symbol_versioning import *
20
21
from bzrlib.trace import mutter
21
22
 
235
236
    external_diff_options
236
237
        If set, use an external GNU diff and pass these options.
237
238
    """
238
 
 
239
239
    old_tree.lock_read()
240
240
    try:
241
241
        new_tree.lock_read()
264
264
    # TODO: Generation of pseudo-diffs for added/deleted files could
265
265
    # be usefully made into a much faster special case.
266
266
 
 
267
    _raise_if_doubly_unversioned(specific_files, old_tree, new_tree)
 
268
 
267
269
    if external_diff_options:
268
270
        assert isinstance(external_diff_options, basestring)
269
271
        opts = external_diff_options.split()
272
274
    else:
273
275
        diff_file = internal_diff
274
276
    
275
 
 
276
277
    delta = compare_trees(old_tree, new_tree, want_unchanged=False,
277
278
                          specific_files=specific_files)
278
279
 
306
307
            _maybe_diff_file_or_symlink(old_label, path, old_tree, file_id,
307
308
                                        new_label, path, new_tree,
308
309
                                        True, kind, to_file, diff_file)
 
310
 
309
311
    return has_changes
 
312
 
 
313
 
 
314
def _raise_if_doubly_unversioned(specific_files, old_tree, new_tree):
 
315
    """Complain if paths are not versioned in either tree."""
 
316
    old_unversioned = old_tree.filter_unversioned_files(specific_files)
 
317
    new_unversioned = new_tree.filter_unversioned_files(specific_files)
 
318
    unversioned = old_unversioned.intersection(new_unversioned)
 
319
    if unversioned:
 
320
        raise errors.PathsNotVersionedError(sorted(unversioned))
310
321
    
311
322
 
312
323
def get_prop_change(meta_modified):