Merge lp:~garyvdm/bzr/extdiff-no-tmp-for-wt into lp:bzr

Proposed by Gary van der Merwe
Status: Merged
Approved by: Martin Pool
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~garyvdm/bzr/extdiff-no-tmp-for-wt
Merge into: lp:bzr
Diff against target: 65 lines (+15/-4)
3 files modified
NEWS (+6/-0)
bzrlib/diff.py (+8/-3)
bzrlib/tests/test_diff.py (+1/-1)
To merge this branch: bzr merge lp:~garyvdm/bzr/extdiff-no-tmp-for-wt
Reviewer Review Type Date Requested Status
Martin Pool Approve
John A Meinel Approve
Review via email: mp+15592@code.launchpad.net

This proposal supersedes a proposal from 2009-12-01.

To post a comment you must log in.
Revision history for this message
Gary van der Merwe (garyvdm) wrote : Posted in a previous version of this proposal

This patch changes bzr behaviour when launching a external diff tool via bzr diff --using. If the file is from a working tree, it does not create a temporary file, rather, it just passes the path to that file in the working tree. This saves writing the file to the disk, but more importantly, allows one to edit the file in diff tools that allow editing, such as meld.

Revision history for this message
Martin Pool (mbp) wrote : Posted in a previous version of this proposal

That's a very nice improvement, and very simple. I recall someone saying there were complications, but if this works for at least some cases, that's great.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Pool wrote:
> Review: Approve
> That's a very nice improvement, and very simple. I recall someone saying there were complications, but if this works for at least some cases, that's great.

It seems to ignore the "force_temp" flag. Would it be better to have:

if not force_temp and isinstance(tree, WorkingTree):
?

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksVlkcACgkQJdeBCYSNAAORBQCfUKV3Lq1vMuwIBBPGqvp5CD4o
QesAoMVWF+iWA/qqufVMN/xKivyZlTLr
=L/NR
-----END PGP SIGNATURE-----

Revision history for this message
Gary van der Merwe (garyvdm) wrote :

Gary van der Merwe wrote on 2009-12-01

> This patch changes bzr behaviour when launching a external diff tool via bzr
> diff --using. If the file is from a working tree, it does not create a
> temporary file, rather, it just passes the path to that file in the working
> tree. This saves writing the file to the disk, but more importantly, allows
> one to edit the file in diff tools that allow editing, such as meld.

This will now still write the temp file if force_temp is true. There are no tests for this, but it currently is not used from anywhere.

Revision history for this message
John A Meinel (jameinel) wrote :

This seems better than what we currently have. So we should merge it as is.

What about deleted files, though?

Also, self._execute looks like it is using relative paths. Do you know if this still works if you are in a subdir of the working tree, etc?

review: Approve
Revision history for this message
Martin Pool (mbp) :
review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-12-03 02:24:54 +0000
+++ NEWS 2009-12-03 07:40:28 +0000
@@ -57,6 +57,12 @@
57 new rich-root heads. This can cut a conversion time in half (mysql from57 new rich-root heads. This can cut a conversion time in half (mysql from
58 13.5h => 6.2h) (John Arbash Meinel, #487632)58 13.5h => 6.2h) (John Arbash Meinel, #487632)
5959
60* When launching a external diff tool via bzr diff --using, temporary files
61 are no longer created, rather, the path to the file in the working tree is
62 passed to the external diff tool. This allows the file to be edited if the
63 diff tool provides for this. (Gary van der Merwe, #490738)
64
65
60Improvements66Improvements
61************67************
6268
6369
=== modified file 'bzrlib/diff.py'
--- bzrlib/diff.py 2009-11-03 01:15:09 +0000
+++ bzrlib/diff.py 2009-12-03 07:40:28 +0000
@@ -39,6 +39,8 @@
39 timestamp,39 timestamp,
40 views,40 views,
41 )41 )
42
43from bzrlib.workingtree import WorkingTree
42""")44""")
4345
44from bzrlib.symbol_versioning import (46from bzrlib.symbol_versioning import (
@@ -722,6 +724,9 @@
722724
723 def _write_file(self, file_id, tree, prefix, relpath, force_temp=False,725 def _write_file(self, file_id, tree, prefix, relpath, force_temp=False,
724 allow_write=False):726 allow_write=False):
727 if not force_temp and isinstance(tree, WorkingTree):
728 return tree.abspath(tree.id2path(file_id))
729
725 full_path = osutils.pathjoin(self._root, prefix, relpath)730 full_path = osutils.pathjoin(self._root, prefix, relpath)
726 if not force_temp and self._try_symlink_root(tree, prefix):731 if not force_temp and self._try_symlink_root(tree, prefix):
727 return full_path732 return full_path
@@ -766,9 +771,9 @@
766 def diff(self, file_id, old_path, new_path, old_kind, new_kind):771 def diff(self, file_id, old_path, new_path, old_kind, new_kind):
767 if (old_kind, new_kind) != ('file', 'file'):772 if (old_kind, new_kind) != ('file', 'file'):
768 return DiffPath.CANNOT_DIFF773 return DiffPath.CANNOT_DIFF
769 self._prepare_files(file_id, old_path, new_path)774 (old_disk_path, new_disk_path) = self._prepare_files(
770 self._execute(osutils.pathjoin('old', old_path),775 file_id, old_path, new_path)
771 osutils.pathjoin('new', new_path))776 self._execute(old_disk_path, new_disk_path)
772777
773 def edit_file(self, file_id):778 def edit_file(self, file_id):
774 """Use this tool to edit a file.779 """Use this tool to edit a file.
775780
=== modified file 'bzrlib/tests/test_diff.py'
--- bzrlib/tests/test_diff.py 2009-10-31 01:16:23 +0000
+++ bzrlib/tests/test_diff.py 2009-12-03 07:40:28 +0000
@@ -1378,7 +1378,7 @@
1378 'newname')1378 'newname')
1379 self.assertContainsRe(old_path, 'old/oldname$')1379 self.assertContainsRe(old_path, 'old/oldname$')
1380 self.assertEqual(0, os.stat(old_path).st_mtime)1380 self.assertEqual(0, os.stat(old_path).st_mtime)
1381 self.assertContainsRe(new_path, 'new/newname$')1381 self.assertContainsRe(new_path, 'tree/newname$')
1382 self.assertFileEqual('oldcontent', old_path)1382 self.assertFileEqual('oldcontent', old_path)
1383 self.assertFileEqual('newcontent', new_path)1383 self.assertFileEqual('newcontent', new_path)
1384 if osutils.host_os_dereferences_symlinks():1384 if osutils.host_os_dereferences_symlinks():