Merge lp:~ace17/bzr/fixDiff4 into lp:bzr
Status: | Needs review |
---|---|
Proposed branch: | lp:~ace17/bzr/fixDiff4 |
Merge into: | lp:bzr |
Diff against target: |
31 lines (+10/-9) 1 file modified
bzrlib/diff.py (+10/-9) |
To merge this branch: | bzr merge lp:~ace17/bzr/fixDiff4 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Richard Wilbur | Needs Fixing | ||
Review via email: mp+222900@code.launchpad.net |
Description of the change
Fixes a bug causing --diff-options being passed to the external GNU diff program when a custom diff tool has been specified.
ace@ANTEC bzr-test % bzr status -V
added:
File1
modified:
File2
ace@ANTEC bzr-test % bzr diff --using gvimdiff --diff-options "-f"
=== added file 'File1'
diff: conflicting output style options
diff: Try `diff --help' for more information.
bzr: ERROR: external diff failed with exit code 2; command: ['diff', '--label', u'File1\t1970-01-01 00:00:00 +0000', '/tmp/bzr-
Unmerged revisions
- 6598. By Sebastien Alaiwan
-
Avoid calling 'external_diff' with options passed to --diff-options if --using is specified. Fixes the following from failing 'bzr add somefile.txt ; bzr diff --using gvimdiff --diff-options '-f -n -d'
Here's what I'm noticing now that I'm digging into this problem a little more deeply: ordinate: ~/src/bzr$ ./bzr --version src/bzr 2.0-64- generic- pae-i686- with-Ubuntu- 12.04-precise diff.py: DiffTree. _show_diff( ) prints the banner CANNOT_ DIFF or we run off the end of the list.
0. First of all, I'm testing on trunk code
rwilbur@
Bazaar (bzr) 2.7.0dev1
from bzr checkout /home/rwilbur/
revision: 6597
revid: <email address hidden>
branch nick: bzr
Python interpreter: /usr/bin/python 2.7.3
Python standard library: /usr/lib/python2.7
Platform: Linux-3.
[...]
1. You have one new file. 'File1' was just added and so has no previous contents in the working tree to calculate a difference from, so bzrlib/
'=== added file 'File1' and then runs a special diff to handle no previous file. bzr creates an empty file with the date and time of the UNIX epoch as a signal to 'patch' that this is a new file and then runs the diff'ers from a list of DiffPath objects till one of them returns a result which is not DiffPath.
As your added 'File1' is lexically earlier than your modified 'File2' and the option '-f' is not a valid option for 'diff', the command ends with the error reported by diff when invoked with '-u -f'. I created a similar test case except my modified 'test.text' is lexically before my added 'test2.text' and so when I get an error on my added file it occurs after already processing the modified file, shown below.
~/src/bzr$ ./bzr status ../test
added:
test2.text
modified:
test.text
~/src/bzr$ ./bzr diff ../test/
=== modified file 'test.text'
--- test.text 2014-06-15 18:31:57 +0000
+++ test.text 2014-06-15 18:32:54 +0000
@@ -1,1 +1,2 @@
test
+testing
=== added file 'test2.text'
--- test2.text 1970-01-01 00:00:00 +0000
+++ test2.text 2014-06-15 21:25:02 +0000
@@ -0,0 +1,1 @@
+test2
Now I invoke it with a '--using' clause to test.
~/src/bzr$ ./bzr diff --using=/bin/ls ../test/ src/test/ test.text diff-609Ozf/ old/test. text
=== modified file 'test.text'
/home/rwilbur/
/tmp/bzr-
=== added file 'test2.text'
--- test2.text 1970-01-01 00:00:00 +0000
+++ test2.text 2014-06-15 21:25:02 +0000
@@ -0,0 +1,1 @@
+test2
It is only used on the modified file as the diff is simulated for the added file. Next I tried using 'cat' instead of 'ls' and this time added a 'diff-options' clause that should number the lines.
~/src/bzr$ ./bzr diff --using=/bin/cat --diff-options='-n' ../test/
=== modified file 'test.text'
1 test
2 test
3 testing
=== added file 'test2.text'
a0 1
test2
So, on the modified file the line from the previous content and the two lines from the new version are concatenated and sequentially numbered. In this case, I'm not seeing the diff options override the using clause(/bin/cat is still being invoked). The added file has different output because the '-n' diff option was used to output a RCS format diff.
~/src/bzr$ ./bzr diff --using=/bin/cat --diff-options='-f' ../test/
=== modified file 'test.text'
/bin/cat: invalid option -- 'f'
Try `/bin/cat --help' for more information.
=== added file 'test2.text'
diff: conflicting output style options
diff: Try `diff --help' for more informatio...