Rev 5384: (mbp) handle diff --using --diff-options in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Aug 20 09:06:54 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5384 [merge]
revision-id: pqm at pqm.ubuntu.com-20100820080653-klig2pem60bl1hz6
parent: pqm at pqm.ubuntu.com-20100820052056-gwad7dz2otckrjax
parent: mbp at sourcefrog.net-20100820064900-hhbu782e4vi06v6d
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-08-20 09:06:53 +0100
message:
  (mbp) handle diff --using --diff-options
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
  bzrlib/tests/blackbox/test_diff.py test_diff.py-20060110203741-aa99ac93e633d971
  bzrlib/tests/features.py       features.py-20090820042958-jglgza3wrn03ha9e-1
=== modified file 'NEWS'
--- a/NEWS	2010-08-18 07:45:14 +0000
+++ b/NEWS	2010-08-20 06:49:00 +0000
@@ -44,6 +44,9 @@
 Bug Fixes
 *********
 
+* Allow using both --using and --diff-options. 
+  (Matthäus G. Chajdas, #234708)
+
 * ``bzr add SYMLINK/FILE`` now works properly when the symlink points to a
   previously-unversioned directory within the tree: the directory is
   marked versioned too.  
@@ -54,9 +57,6 @@
   regular expression.
   (Parth Malwankar #300062)
 
-* Check if both --diff-options and --using are set, and exit with error
-  in this case. (Matthäus G. Chajdas, #234708)
-
 * CommitBuilder now uses the committer instead of _config.username to generate
   the revision-id.  (Aaron Bentley, #614404)
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-08-11 05:48:09 +0000
+++ b/bzrlib/builtins.py	2010-08-20 06:49:00 +0000
@@ -1884,12 +1884,16 @@
         Same as 'bzr diff' but prefix paths with old/ and new/::
 
             bzr diff --prefix old/:new/
+            
+        Show the differences using a custom diff program with options::
+        
+            bzr diff --using /usr/bin/diff --diff-options -wu
     """
     _see_also = ['status']
     takes_args = ['file*']
     takes_options = [
         Option('diff-options', type=str,
-               help='Pass these options to the diff program.'),
+               help='Pass these options to the external diff program.'),
         Option('prefix', type=str,
                short_name='p',
                help='Set prefixes added to old and new filenames, as '
@@ -1936,10 +1940,6 @@
                 '--prefix expects two values separated by a colon'
                 ' (eg "old/:new/")')
 
-        if using is not None and diff_options is not None:
-            raise errors.BzrCommandError(
-            '--diff-options and --using are mutually exclusive.')
-
         if revision and len(revision) > 2:
             raise errors.BzrCommandError('bzr diff --revision takes exactly'
                                          ' one or two revision specifiers')

=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py	2010-07-16 15:20:17 +0000
+++ b/bzrlib/diff.py	2010-08-20 06:49:00 +0000
@@ -736,9 +736,12 @@
                      path_encoding)
 
     @classmethod
-    def make_from_diff_tree(klass, command_string):
+    def make_from_diff_tree(klass, command_string, external_diff_options=None):
         def from_diff_tree(diff_tree):
-            return klass.from_string(command_string, diff_tree.old_tree,
+            full_command_string = [command_string]
+            if external_diff_options is not None:
+                full_command_string += ' ' + external_diff_options
+            return klass.from_string(full_command_string, diff_tree.old_tree,
                                      diff_tree.new_tree, diff_tree.to_file)
         return from_diff_tree
 
@@ -912,7 +915,7 @@
         :param using: Commandline to use to invoke an external diff tool
         """
         if using is not None:
-            extra_factories = [DiffFromTool.make_from_diff_tree(using)]
+            extra_factories = [DiffFromTool.make_from_diff_tree(using, external_diff_options)]
         else:
             extra_factories = []
         if external_diff_options:

=== modified file 'bzrlib/tests/blackbox/test_diff.py'
--- a/bzrlib/tests/blackbox/test_diff.py	2010-07-18 06:54:01 +0000
+++ b/bzrlib/tests/blackbox/test_diff.py	2010-07-22 13:19:48 +0000
@@ -29,6 +29,9 @@
     DiffTree,
     format_registry as diff_format_registry,
     )
+from bzrlib.tests import (
+    features,
+    )
 
 
 def subst_dates(string):
@@ -155,10 +158,6 @@
         self.assertContainsRe(err,
             "Requested revision: '1.1' does not exist in branch:")
 
-    def test_diff_diff_options_and_using(self):
-        out, err = self.run_bzr('diff --diff-options -wu --using /usr/bin/diff', retcode=3,
-          error_regexes=('are mutually exclusive.',))
-
     def test_diff_unversioned(self):
         # Get an error when diffing a non-versioned file.
         # (Malone #3619)
@@ -403,6 +402,16 @@
         self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n"
                                  "+baz\n\n")
 
+    def test_external_diff_options_and_using(self):
+        """Test that the options are passed correctly to an external diff process"""
+        self.requireFeature(features.diff_feature)
+        self.make_example_branch()
+        self.build_tree_contents([('hello', 'Foo\n')])
+        out, err = self.run_bzr('diff --diff-options -i --using diff',
+                                    retcode=1)
+        self.assertEquals("=== modified file 'hello'\n", out)
+        self.assertEquals('', err)
+
 
 class TestDiffOutput(DiffBase):
 

=== modified file 'bzrlib/tests/features.py'
--- a/bzrlib/tests/features.py	2010-07-05 12:40:28 +0000
+++ b/bzrlib/tests/features.py	2010-08-20 06:49:00 +0000
@@ -114,3 +114,4 @@
 
 bash_feature = ExecutableFeature('bash')
 sed_feature = ExecutableFeature('sed')
+diff_feature = ExecutableFeature('diff')




More information about the bazaar-commits mailing list