785
785
self.to_file.write(proc.stdout.read())
786
786
return proc.wait()
788
def _write_file(self, file_id, tree, prefix, old_path):
789
full_old_path = osutils.pathjoin(self._root, prefix, old_path)
790
parent_dir = osutils.dirname(full_old_path)
788
def _try_symlink_root(self, tree, prefix):
789
if not (getattr(tree, 'abspath', None) is not None
790
and osutils.has_symlinks()):
793
os.symlink(tree.abspath(''), osutils.pathjoin(self._root, prefix))
795
if e.errno != errno.EEXIST:
799
def _write_file(self, file_id, tree, prefix, relpath):
800
full_path = osutils.pathjoin(self._root, prefix, relpath)
801
if self._try_symlink_root(tree, prefix):
803
parent_dir = osutils.dirname(full_path)
792
805
os.makedirs(parent_dir)
793
806
except OSError, e:
794
807
if e.errno != errno.EEXIST:
796
source = tree.get_file(file_id)
809
source = tree.get_file(file_id, relpath)
798
target = open(full_old_path, 'wb')
811
target = open(full_path, 'wb')
800
813
osutils.pumpfile(source, target)
818
osutils.make_readonly(full_path)
819
mtime = tree.get_file_mtime(file_id)
820
os.utime(full_path, (mtime, mtime))
807
823
def _prepare_files(self, file_id, old_path, new_path):
808
824
old_disk_path = self._write_file(file_id, self.old_tree, 'old',
812
828
return old_disk_path, new_disk_path
814
830
def finish(self):
815
shutil.rmtree(self._root)
831
osutils.rmtree(self._root)
817
833
def diff(self, file_id, old_path, new_path, old_kind, new_kind):
818
834
if (old_kind, new_kind) != ('file', 'file'):