Merge lp:~anteru/bzr/234708-diff into lp:bzr

Proposed by Matthäus G. Chajdas
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5384
Proposed branch: lp:~anteru/bzr/234708-diff
Merge into: lp:bzr
Diff against target: 134 lines (+30/-12) (has conflicts)
5 files modified
NEWS (+5/-0)
bzrlib/builtins.py (+5/-5)
bzrlib/diff.py (+6/-3)
bzrlib/tests/blackbox/test_diff.py (+13/-4)
bzrlib/tests/features.py (+1/-0)
Text conflict in NEWS
To merge this branch: bzr merge lp:~anteru/bzr/234708-diff
Reviewer Review Type Date Requested Status
Martin Pool Approve
Vincent Ladeuil Approve
Review via email: mp+30318@code.launchpad.net

Commit message

accept both --diff-options and --using

Description of the change

Support both --using and --diff-options

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Two things:

- NEWS entries are sorted, put yours first since it starts with 'Allow',

- look at bzrlib.tests.features, there is some support available to define a feature that can check for the availability of an executable (sed, bash). That would allow you to write the test without relying on a particular path (/usr/bin/diff)

review: Needs Fixing
Revision history for this message
Vincent Ladeuil (vila) wrote :

I added a diff_feature as suggested above, the result is at lp:~vila/bzr/234708-diff-using-and-diff-options

You can pull or merge the above branch and resubmit.

We need a second reviewer here that could land the result if approved.

Forget my remark about NEWS, launchpad doesn't use the news_merge plugin that should take care of the conflict, your branch has a single entry in the bugs section so nothing you can do to avoid this conflict ;)

Revision history for this message
Vincent Ladeuil (vila) wrote :

Well done !

We need a second reviewer now.

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

very nice, thanks. sorry for the long delay.

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

sent to pqm by email

Revision history for this message
Matthäus G. Chajdas (anteru) wrote :

Cool, thanks -- that's my first contribution to Bazaar, and I must say that the process is really painless.

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

there were conflicts; i've addressed them and resubmitted from lp:~mbp/bzr/integration.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-07-21 22:29:45 +0000
3+++ NEWS 2010-07-22 13:21:47 +0000
4@@ -28,6 +28,7 @@
5 Bug Fixes
6 *********
7
8+<<<<<<< TREE
9 * Check if both --diff-options and --using are set, and exit with error
10 in this case. (Matthäus G. Chajdas, #234708)
11
12@@ -44,6 +45,10 @@
13 to a symlink, now returns information about the symlink.
14 (Martin Pool)
15
16+=======
17+* Allow using both --using and --diff-options. (Matthäus G. Chajdas, #234708)
18+
19+>>>>>>> MERGE-SOURCE
20 Improvements
21 ************
22
23
24=== modified file 'bzrlib/builtins.py'
25--- bzrlib/builtins.py 2010-07-20 10:18:05 +0000
26+++ bzrlib/builtins.py 2010-07-22 13:21:47 +0000
27@@ -1879,12 +1879,16 @@
28 Same as 'bzr diff' but prefix paths with old/ and new/::
29
30 bzr diff --prefix old/:new/
31+
32+ Show the differences using a custom diff program with options::
33+
34+ bzr diff --using /usr/bin/diff --diff-options -wu
35 """
36 _see_also = ['status']
37 takes_args = ['file*']
38 takes_options = [
39 Option('diff-options', type=str,
40- help='Pass these options to the diff program.'),
41+ help='Pass these options to the external diff program.'),
42 Option('prefix', type=str,
43 short_name='p',
44 help='Set prefixes added to old and new filenames, as '
45@@ -1931,10 +1935,6 @@
46 '--prefix expects two values separated by a colon'
47 ' (eg "old/:new/")')
48
49- if using is not None and diff_options is not None:
50- raise errors.BzrCommandError(
51- '--diff-options and --using are mutually exclusive.')
52-
53 if revision and len(revision) > 2:
54 raise errors.BzrCommandError('bzr diff --revision takes exactly'
55 ' one or two revision specifiers')
56
57=== modified file 'bzrlib/diff.py'
58--- bzrlib/diff.py 2010-07-16 15:20:17 +0000
59+++ bzrlib/diff.py 2010-07-22 13:21:47 +0000
60@@ -736,9 +736,12 @@
61 path_encoding)
62
63 @classmethod
64- def make_from_diff_tree(klass, command_string):
65+ def make_from_diff_tree(klass, command_string, external_diff_options=None):
66 def from_diff_tree(diff_tree):
67- return klass.from_string(command_string, diff_tree.old_tree,
68+ full_command_string = [command_string]
69+ if external_diff_options is not None:
70+ full_command_string += ' ' + external_diff_options
71+ return klass.from_string(full_command_string, diff_tree.old_tree,
72 diff_tree.new_tree, diff_tree.to_file)
73 return from_diff_tree
74
75@@ -912,7 +915,7 @@
76 :param using: Commandline to use to invoke an external diff tool
77 """
78 if using is not None:
79- extra_factories = [DiffFromTool.make_from_diff_tree(using)]
80+ extra_factories = [DiffFromTool.make_from_diff_tree(using, external_diff_options)]
81 else:
82 extra_factories = []
83 if external_diff_options:
84
85=== modified file 'bzrlib/tests/blackbox/test_diff.py'
86--- bzrlib/tests/blackbox/test_diff.py 2010-07-18 06:54:01 +0000
87+++ bzrlib/tests/blackbox/test_diff.py 2010-07-22 13:21:47 +0000
88@@ -29,6 +29,9 @@
89 DiffTree,
90 format_registry as diff_format_registry,
91 )
92+from bzrlib.tests import (
93+ features,
94+ )
95
96
97 def subst_dates(string):
98@@ -155,10 +158,6 @@
99 self.assertContainsRe(err,
100 "Requested revision: '1.1' does not exist in branch:")
101
102- def test_diff_diff_options_and_using(self):
103- out, err = self.run_bzr('diff --diff-options -wu --using /usr/bin/diff', retcode=3,
104- error_regexes=('are mutually exclusive.',))
105-
106 def test_diff_unversioned(self):
107 # Get an error when diffing a non-versioned file.
108 # (Malone #3619)
109@@ -403,6 +402,16 @@
110 self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n"
111 "+baz\n\n")
112
113+ def test_external_diff_options_and_using(self):
114+ """Test that the options are passed correctly to an external diff process"""
115+ self.requireFeature(features.diff_feature)
116+ self.make_example_branch()
117+ self.build_tree_contents([('hello', 'Foo\n')])
118+ out, err = self.run_bzr('diff --diff-options -i --using diff',
119+ retcode=1)
120+ self.assertEquals("=== modified file 'hello'\n", out)
121+ self.assertEquals('', err)
122+
123
124 class TestDiffOutput(DiffBase):
125
126
127=== modified file 'bzrlib/tests/features.py'
128--- bzrlib/tests/features.py 2010-07-05 12:40:28 +0000
129+++ bzrlib/tests/features.py 2010-07-22 13:21:47 +0000
130@@ -114,3 +114,4 @@
131
132 bash_feature = ExecutableFeature('bash')
133 sed_feature = ExecutableFeature('sed')
134+diff_feature = ExecutableFeature('diff')