~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-06-05 04:05:05 UTC
  • mfrom: (3473.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080605040505-i9kqxg2fps2qjdi0
Add the 'alias' command (Tim Penhey)

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 warning
 
46
from bzrlib.trace import mutter, 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
 
    return spec.as_tree(branch)
 
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)
374
377
 
375
378
 
376
379
def _relative_paths_in_tree(tree, paths):
439
442
    return timestamp.format_patch_date(mtime)
440
443
 
441
444
 
 
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
 
442
464
@deprecated_function(one_three)
443
465
def get_prop_change(meta_modified):
444
466
    if meta_modified:
660
682
                 path_encoding='utf-8'):
661
683
        DiffPath.__init__(self, old_tree, new_tree, to_file, path_encoding)
662
684
        self.command_template = command_template
663
 
        self._root = osutils.mkdtemp(prefix='bzr-diff-')
 
685
        self._root = tempfile.mkdtemp(prefix='bzr-diff-')
664
686
 
665
687
    @classmethod
666
688
    def from_string(klass, command_string, old_tree, new_tree, to_file,
695
717
        return proc.wait()
696
718
 
697
719
    def _try_symlink_root(self, tree, prefix):
698
 
        if (getattr(tree, 'abspath', None) is None
699
 
            or not osutils.host_os_dereferences_symlinks()):
 
720
        if not (getattr(tree, 'abspath', None) is not None
 
721
                and osutils.has_symlinks()):
700
722
            return False
701
723
        try:
702
724
            os.symlink(tree.abspath(''), osutils.pathjoin(self._root, prefix))
852
874
                return path.encode(self.path_encoding, "replace")
853
875
        for (file_id, paths, changed_content, versioned, parent, name, kind,
854
876
             executable) in sorted(iterator, key=changes_key):
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):
 
877
            if parent == (None, None):
858
878
                continue
859
879
            oldpath, newpath = paths
860
880
            oldpath_encoded = get_encoded_path(paths[0])