~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Aaron Bentley
  • Date: 2009-08-14 15:26:25 UTC
  • mto: (4603.1.22 shelve-editor)
  • mto: This revision was merged to the branch mainline in revision 4795.
  • Revision ID: aaron@aaronbentley.com-20090814152625-mq53zoazsepp1xtw
Initial pass at shelve-via-editor.

Show diffs side-by-side

added added

removed removed

Lines of Context:
664
664
        DiffPath.__init__(self, old_tree, new_tree, to_file, path_encoding)
665
665
        self.command_template = command_template
666
666
        self._root = osutils.mkdtemp(prefix='bzr-diff-')
 
667
        self.force_temp = False
 
668
        self.allow_write = False
667
669
 
668
670
    @classmethod
669
671
    def from_string(klass, command_string, old_tree, new_tree, to_file,
710
712
 
711
713
    def _write_file(self, file_id, tree, prefix, relpath):
712
714
        full_path = osutils.pathjoin(self._root, prefix, relpath)
713
 
        if self._try_symlink_root(tree, prefix):
 
715
        if not self.force_temp and self._try_symlink_root(tree, prefix):
714
716
            return full_path
715
717
        parent_dir = osutils.dirname(full_path)
716
718
        try:
727
729
                target.close()
728
730
        finally:
729
731
            source.close()
730
 
        osutils.make_readonly(full_path)
 
732
        if not self.allow_write:
 
733
            osutils.make_readonly(full_path)
731
734
        mtime = tree.get_file_mtime(file_id)
732
735
        os.utime(full_path, (mtime, mtime))
733
736
        return full_path
752
755
            return DiffPath.CANNOT_DIFF
753
756
        self._prepare_files(file_id, old_path, new_path)
754
757
        self._execute(osutils.pathjoin('old', old_path),
755
 
                      osutils.pathjoin('new', new_path))
 
758
                      self.get_new_path(new_path))
 
759
 
 
760
    def get_new_path(self, new_path, abspath=False):
 
761
        if abspath:
 
762
            components = [self._root]
 
763
        else:
 
764
            components = []
 
765
        components.extend(['new', new_path])
 
766
        return osutils.pathjoin(*components)
756
767
 
757
768
 
758
769
class DiffTree(object):