390
390
make_paths_wt_relative = True
391
consider_relpath = True
391
392
if path_list is None or len(path_list) == 0:
392
# If no path is given, assume the current directory
393
# If no path is given, the current working tree is used
393
394
default_location = u'.'
395
consider_relpath = False
394
396
elif old_url is not None and new_url is not None:
395
397
other_paths = path_list
396
398
make_paths_wt_relative = False
404
406
old_url = default_location
405
407
working_tree, branch, relpath = \
406
408
bzrdir.BzrDir.open_containing_tree_or_branch(old_url)
409
if consider_relpath and relpath != '':
408
410
specific_files.append(relpath)
409
411
old_tree = _get_tree_to_diff(old_revision_spec, working_tree, branch)
414
416
if new_url != old_url:
415
417
working_tree, branch, relpath = \
416
418
bzrdir.BzrDir.open_containing_tree_or_branch(new_url)
419
if consider_relpath and relpath != '':
418
420
specific_files.append(relpath)
419
421
new_tree = _get_tree_to_diff(new_revision_spec, working_tree, branch,
420
422
basis_is_default=working_tree is None)
773
775
return [t % my_map for t in self.command_template]
775
777
def _execute(self, old_path, new_path):
776
proc = subprocess.Popen(self._get_command(old_path, new_path),
777
stdout=subprocess.PIPE, cwd=self._root)
778
command = self._get_command(old_path, new_path)
780
proc = subprocess.Popen(command, stdout=subprocess.PIPE,
783
if e.errno == errno.ENOENT:
784
raise errors.ExecutableMissing(command[0])
778
787
self.to_file.write(proc.stdout.read())
779
788
return proc.wait()
781
def _write_file(self, file_id, tree, prefix, old_path):
782
full_old_path = osutils.pathjoin(self._root, prefix, old_path)
783
parent_dir = osutils.dirname(full_old_path)
790
def _try_symlink_root(self, tree, prefix):
791
if not (getattr(tree, 'abspath', None) is not None
792
and osutils.has_symlinks()):
795
os.symlink(tree.abspath(''), osutils.pathjoin(self._root, prefix))
797
if e.errno != errno.EEXIST:
801
def _write_file(self, file_id, tree, prefix, relpath):
802
full_path = osutils.pathjoin(self._root, prefix, relpath)
803
if self._try_symlink_root(tree, prefix):
805
parent_dir = osutils.dirname(full_path)
785
807
os.makedirs(parent_dir)
786
808
except OSError, e:
787
809
if e.errno != errno.EEXIST:
789
source = tree.get_file(file_id)
811
source = tree.get_file(file_id, relpath)
791
target = open(full_old_path, 'wb')
813
target = open(full_path, 'wb')
793
815
osutils.pumpfile(source, target)
820
osutils.make_readonly(full_path)
821
mtime = tree.get_file_mtime(file_id)
822
os.utime(full_path, (mtime, mtime))
800
825
def _prepare_files(self, file_id, old_path, new_path):
801
826
old_disk_path = self._write_file(file_id, self.old_tree, 'old',
805
830
return old_disk_path, new_disk_path
807
832
def finish(self):
808
shutil.rmtree(self._root)
833
osutils.rmtree(self._root)
810
835
def diff(self, file_id, old_path, new_path, old_kind, new_kind):
811
836
if (old_kind, new_kind) != ('file', 'file'):