~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

1st cut merge of bzr.dev r3907

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        deprecated_function,
44
44
        one_three
45
45
        )
46
 
from bzrlib.trace import mutter, warning
 
46
from bzrlib.trace import warning
47
47
 
48
48
 
49
49
# TODO: Rather than building a changeset object, we should probably
370
370
                return branch.basis_tree()
371
371
        else:
372
372
            return tree
373
 
    if not spec.needs_branch():
374
 
        branch = _mod_branch.Branch.open(spec.get_branch())
375
 
    revision_id = spec.as_revision_id(branch)
376
 
    return branch.repository.revision_tree(revision_id)
 
373
    return spec.as_tree(branch)
377
374
 
378
375
 
379
376
def _relative_paths_in_tree(tree, paths):
442
439
    return timestamp.format_patch_date(mtime)
443
440
 
444
441
 
445
 
def _raise_if_nonexistent(paths, old_tree, new_tree):
446
 
    """Complain if paths are not in either inventory or tree.
447
 
 
448
 
    It's OK with the files exist in either tree's inventory, or 
449
 
    if they exist in the tree but are not versioned.
450
 
    
451
 
    This can be used by operations such as bzr status that can accept
452
 
    unknown or ignored files.
453
 
    """
454
 
    mutter("check paths: %r", paths)
455
 
    if not paths:
456
 
        return
457
 
    s = old_tree.filter_unversioned_files(paths)
458
 
    s = new_tree.filter_unversioned_files(s)
459
 
    s = [path for path in s if not new_tree.has_filename(path)]
460
 
    if s:
461
 
        raise errors.PathsDoNotExist(sorted(s))
462
 
 
463
 
 
464
442
@deprecated_function(one_three)
465
443
def get_prop_change(meta_modified):
466
444
    if meta_modified:
682
660
                 path_encoding='utf-8'):
683
661
        DiffPath.__init__(self, old_tree, new_tree, to_file, path_encoding)
684
662
        self.command_template = command_template
685
 
        self._root = tempfile.mkdtemp(prefix='bzr-diff-')
 
663
        self._root = osutils.mkdtemp(prefix='bzr-diff-')
686
664
 
687
665
    @classmethod
688
666
    def from_string(klass, command_string, old_tree, new_tree, to_file,
874
852
                return path.encode(self.path_encoding, "replace")
875
853
        for (file_id, paths, changed_content, versioned, parent, name, kind,
876
854
             executable) in sorted(iterator, key=changes_key):
877
 
            if parent == (None, None):
 
855
            # The root does not get diffed, and items with no known kind (that
 
856
            # is, missing) in both trees are skipped as well.
 
857
            if parent == (None, None) or kind == (None, None):
878
858
                continue
879
859
            oldpath, newpath = paths
880
860
            oldpath_encoded = get_encoded_path(paths[0])