Rev 5513: Merge bzr.dev into config-active in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Nov 8 15:04:34 GMT 2010


At file:///home/vila/src/bzr/experimental/config/

------------------------------------------------------------
revno: 5513 [merge]
revision-id: v.ladeuil+lp at free.fr-20101108150434-ww8g3ekhoda13suh
parent: v.ladeuil+lp at free.fr-20101106170942-rfe9b5bo2a7879cb
parent: pqm at pqm.ubuntu.com-20101108134551-sxvk77ehmegkrwmm
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-active
timestamp: Mon 2010-11-08 16:04:34 +0100
message:
  Merge bzr.dev into config-active
modified:
  bzrlib/cmd_test_script.py      cmd_test_script.py-20101020120519-7hst41avona524nn-1
  bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
  bzrlib/conflicts.py            conflicts.py-20051001061850-78ef952ba63d2b42
  bzrlib/tests/blackbox/test_conflicts.py test_conflicts.py-20060228151432-9723ebb925b999cf
  bzrlib/tests/blackbox/test_exceptions.py test_exceptions.py-20060604211237-yi2cxg0ose3xk4id-1
  bzrlib/tests/blackbox/test_script.py test_script.py-20101013135628-rw9f11dgkgx09fnq-1
  bzrlib/tests/script.py         script.py-20090901081155-yk3tiy1nunxg16ne-1
  bzrlib/tests/test_script.py    test_script.py-20090901081156-y90z4w2t62fv7e7b-1
  bzrlib/tests/test_workingtree.py testworkingtree.py-20051004024258-b88d0fe8f101d468
  bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
  doc/developers/testing.txt     testing.txt-20080812140359-i70zzh6v2z7grqex-1
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
-------------- next part --------------
=== modified file 'bzrlib/cmd_test_script.py'
--- a/bzrlib/cmd_test_script.py	2010-11-05 20:54:32 +0000
+++ b/bzrlib/cmd_test_script.py	2010-11-08 10:53:53 +0000
@@ -16,13 +16,16 @@
 
 """Front-end command for shell-like test scripts.
 
-See developers/testing.html for more explanations.
+See doc/developers/testing.txt for more explanations.
 This module should be importable even if testtools aren't available.
 """
 
 import os
 
-from bzrlib import commands
+from bzrlib import (
+    commands,
+    option,
+    )
 
 
 class cmd_test_script(commands.Command):
@@ -30,9 +33,13 @@
 
     hidden = True
     takes_args = ['infile']
+    takes_options = [
+        option.Option('null-output',
+                       help='Null command outputs match any output.'),
+        ]
 
     @commands.display_command
-    def run(self, infile):
+    def run(self, infile, null_output=False):
         # local imports to defer testtools dependency
         from bzrlib import tests
         from bzrlib.tests.script import TestCaseWithTransportAndScript
@@ -48,7 +55,8 @@
             script = None # Set before running
 
             def test_it(self):
-                self.run_script(script)
+                self.run_script(script,
+                                null_output_matches_anything=null_output)
 
         runner = tests.TextTestRunner(stream=self.outf)
         test = Test('test_it')

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2010-10-08 06:22:30 +0000
+++ b/bzrlib/commands.py	2010-10-29 17:07:42 +0000
@@ -815,7 +815,13 @@
     else:
         args = argv
 
-    options, args = parser.parse_args(args)
+    # for python 2.5 and later, optparse raises this exception if a non-ascii
+    # option name is given.  See http://bugs.python.org/issue2931
+    try:
+        options, args = parser.parse_args(args)
+    except UnicodeEncodeError,e:
+        raise errors.BzrCommandError('Only ASCII permitted in option names')
+
     opts = dict([(k, v) for k, v in options.__dict__.iteritems() if
                  v is not option.OptionParser.DEFAULT_VALUE])
     return args, opts

=== modified file 'bzrlib/conflicts.py'
--- a/bzrlib/conflicts.py	2010-11-04 17:48:47 +0000
+++ b/bzrlib/conflicts.py	2010-11-07 13:38:56 +0000
@@ -602,12 +602,9 @@
         self._resolve_with_cleanups(tree, 'THIS')
 
 
-# FIXME: TextConflict is about a single file-id, there never is a conflict_path
-# attribute so we shouldn't inherit from PathConflict but simply from Conflict
-
 # TODO: There should be a base revid attribute to better inform the user about
 # how the conflicts were generated.
-class TextConflict(PathConflict):
+class TextConflict(Conflict):
     """The merge algorithm could not resolve all differences encountered."""
 
     has_files = True
@@ -616,6 +613,8 @@
 
     format = 'Text conflict in %(path)s'
 
+    rformat = '%(class)s(%(path)r, %(file_id)r)'
+
     def associated_filenames(self):
         return [self.path + suffix for suffix in CONFLICT_SUFFIXES]
 

=== modified file 'bzrlib/tests/blackbox/test_conflicts.py'
--- a/bzrlib/tests/blackbox/test_conflicts.py	2010-11-04 17:48:47 +0000
+++ b/bzrlib/tests/blackbox/test_conflicts.py	2010-11-07 13:38:56 +0000
@@ -19,6 +19,8 @@
     tests,
     workingtree,
     )
+from bzrlib.tests import script
+
 
 # FIXME: These don't really look at the output of the conflict commands, just
 # the number of lines - there should be more examination.
@@ -131,3 +133,46 @@
         self.assertEqual('', err)
         out, err = self.run_bzr('conflicts')
         self.assertEqual(0, len(out.splitlines()))
+
+class TestResolveSilentlyIgnore(script.TestCaseWithTransportAndScript):
+
+    def test_bug_646961(self):
+        self.run_script("""\
+            $ bzr init base
+            Created a standalone tree (format: 2a)
+            $ cd base
+            $ echo >file1
+            $ bzr add
+            adding file1
+            $ bzr ci -m "stuff"
+            2>Committing to: .../base/
+            2>added file1
+            2>Committed revision 1.
+            $ cd ..
+            $ bzr branch base branch
+            2>Branched 1 revision(s).
+            $ cd base
+            $ echo "1" >> file1
+            $ bzr ci -m "branch 1"
+            2>Committing to: .../base/
+            2>modified file1
+            2>Committed revision 2.
+            $ cd ../branch
+            $ echo "2" >> file1
+            $ bzr ci -m "branch 2"
+            2>Committing to: .../branch/
+            2>modified file1
+            2>Committed revision 2.
+            $ cd ../base
+            $ bzr merge ../branch
+            2> M  file1
+            2>Text conflict in file1
+            2>1 conflicts encountered.
+            # The following succeeds silently without resolving the conflict
+            $ bzr resolve file1 --take-other
+            # The following wil fail when --take-other is implemented
+            # for text conflicts
+            $ bzr conflicts
+            Text conflict in file1
+            """)
+

=== modified file 'bzrlib/tests/blackbox/test_exceptions.py'
--- a/bzrlib/tests/blackbox/test_exceptions.py	2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/blackbox/test_exceptions.py	2010-11-06 15:32:00 +0000
@@ -48,6 +48,18 @@
         self.assertContainsRe(err, r'Bazaar has encountered an internal error')
 
 
+class TestOptParseBugHandling(TestCase):
+    "Test that we handle http://bugs.python.org/issue2931"
+
+    def test_nonascii_optparse(self):
+        """Reasonable error raised when non-ascii in option name"""
+        if sys.version_info < (2,5):
+            error_re = 'no such option'
+        else:
+            error_re = 'Only ASCII permitted in option names'
+        out = self.run_bzr_error([error_re], ['st',u'-\xe4'])
+
+
 class TestDeprecationWarning(tests.TestCaseWithTransport):
     """The deprecation warning is controlled via a global variable:
     repository._deprecation_warning_done. As such, it can be emitted only once

=== modified file 'bzrlib/tests/blackbox/test_script.py'
--- a/bzrlib/tests/blackbox/test_script.py	2010-10-13 13:57:22 +0000
+++ b/bzrlib/tests/blackbox/test_script.py	2010-11-08 10:53:53 +0000
@@ -50,6 +50,16 @@
         self.assertEquals('OK', out_lines[-1])
         self.assertEquals('', err)
 
+    def test_null_output(self):
+        self.build_tree_contents([('script', '''
+$ echo hello world
+''')])
+        out, err = self.run_bzr(['test-script', 'script', '--null-output'])
+        out_lines = out.splitlines()
+        self.assertStartsWith(out_lines[-3], 'Ran 1 test in ')
+        self.assertEquals('OK', out_lines[-1])
+        self.assertEquals('', err)
+
     def test_failing_script(self):
         self.build_tree_contents([('script', '''
 $ echo hello foo

=== modified file 'bzrlib/tests/script.py'
--- a/bzrlib/tests/script.py	2010-10-28 00:06:59 +0000
+++ b/bzrlib/tests/script.py	2010-11-08 09:58:04 +0000
@@ -196,7 +196,7 @@
         self.output_checker = doctest.OutputChecker()
         self.check_options = doctest.ELLIPSIS
 
-    def run_script(self, test_case, text):
+    def run_script(self, test_case, text, null_output_matches_anything=False):
         """Run a shell-like script as a test.
 
         :param test_case: A TestCase instance that should provide the fail(),
@@ -204,7 +204,12 @@
             attribute used as a jail root.
 
         :param text: A shell-like script (see _script_to_commands for syntax).
+
+        :param null_output_matches_anything: For commands with no specified
+            output, ignore any output that does happen, including output on
+            standard error.
         """
+        self.null_output_matches_anything = null_output_matches_anything
         for cmd, input, output, error in _script_to_commands(text):
             self.run_command(test_case, cmd, input, output, error)
 
@@ -245,6 +250,12 @@
             else:
                 test_case.fail('expected output: %r, but found nothing'
                             % (expected,))
+
+        null_output_matches_anything = getattr(
+            self, 'null_output_matches_anything', False)
+        if null_output_matches_anything and expected is None:
+            return
+
         expected = expected or ''
         matching = self.output_checker.check_output(
             expected, actual, self.check_options)
@@ -473,8 +484,9 @@
         super(TestCaseWithMemoryTransportAndScript, self).setUp()
         self.script_runner = ScriptRunner()
 
-    def run_script(self, script):
-        return self.script_runner.run_script(self, script)
+    def run_script(self, script, null_output_matches_anything=False):
+        return self.script_runner.run_script(self, script, 
+                   null_output_matches_anything=null_output_matches_anything)
 
     def run_command(self, cmd, input, output, error):
         return self.script_runner.run_command(self, cmd, input, output, error)
@@ -502,14 +514,16 @@
         super(TestCaseWithTransportAndScript, self).setUp()
         self.script_runner = ScriptRunner()
 
-    def run_script(self, script):
-        return self.script_runner.run_script(self, script)
+    def run_script(self, script, null_output_matches_anything=False):
+        return self.script_runner.run_script(self, script,
+                   null_output_matches_anything=null_output_matches_anything)
 
     def run_command(self, cmd, input, output, error):
         return self.script_runner.run_command(self, cmd, input, output, error)
 
 
-def run_script(test_case, script_string):
+def run_script(test_case, script_string, null_output_matches_anything=False):
     """Run the given script within a testcase"""
-    return ScriptRunner().run_script(test_case, script_string)
+    return ScriptRunner().run_script(test_case, script_string,
+               null_output_matches_anything=null_output_matches_anything)
 

=== modified file 'bzrlib/tests/test_script.py'
--- a/bzrlib/tests/test_script.py	2010-10-27 23:27:41 +0000
+++ b/bzrlib/tests/test_script.py	2010-11-08 09:58:04 +0000
@@ -186,6 +186,14 @@
             $ echo foo
             """)
 
+    def test_null_output_matches_option(self):
+        """If you want null output to be a wild card, you can pass 
+        null_output_matches_anything to run_script"""
+        self.run_script(
+            """
+            $ echo foo
+            """, null_output_matches_anything=True)
+
     def test_ellipsis_everything(self):
         """A simple ellipsis matches everything."""
         self.run_script("""

=== modified file 'bzrlib/tests/test_workingtree.py'
--- a/bzrlib/tests/test_workingtree.py	2010-06-20 11:18:38 +0000
+++ b/bzrlib/tests/test_workingtree.py	2010-11-07 10:20:30 +0000
@@ -349,28 +349,28 @@
         self.build_tree_contents([('this/hello', 'Hello World')])
         this.commit('Add World')
         this.merge_from_branch(other.branch)
-        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
+        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
                          this.conflicts())
         this.auto_resolve()
-        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
+        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
                          this.conflicts())
         self.build_tree_contents([('this/hello', '<<<<<<<')])
         this.auto_resolve()
-        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
+        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
                          this.conflicts())
         self.build_tree_contents([('this/hello', '=======')])
         this.auto_resolve()
-        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
+        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
                          this.conflicts())
         self.build_tree_contents([('this/hello', '\n>>>>>>>')])
         remaining, resolved = this.auto_resolve()
-        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
+        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
                          this.conflicts())
         self.assertEqual([], resolved)
         self.build_tree_contents([('this/hello', 'hELLO wORLD')])
         remaining, resolved = this.auto_resolve()
         self.assertEqual([], this.conflicts())
-        self.assertEqual([conflicts.TextConflict('hello', None, 'hello_id')],
+        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
                          resolved)
         self.failIfExists('this/hello.BASE')
 
@@ -378,7 +378,7 @@
         tree = self.make_branch_and_tree('tree')
         self.build_tree(['tree/hello/'])
         tree.add('hello', 'hello-id')
-        file_conflict = conflicts.TextConflict('file', None, 'hello-id')
+        file_conflict = conflicts.TextConflict('file', 'hello-id')
         tree.set_conflicts(conflicts.ConflictList([file_conflict]))
         tree.auto_resolve()
 

=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py	2010-10-15 14:57:42 +0000
+++ b/bzrlib/transform.py	2010-11-07 13:38:56 +0000
@@ -666,9 +666,14 @@
         if (self._new_name, self._new_parent) == ({}, {}):
             return conflicts
         for children in by_parent.itervalues():
-            name_ids = [(self.final_name(t), t) for t in children]
-            if not self._case_sensitive_target:
-                name_ids = [(n.lower(), t) for n, t in name_ids]
+            name_ids = []
+            for child_tid in children:
+                name = self.final_name(child_tid)
+                if name is not None:
+                    # Keep children only if they still exist in the end
+                    if not self._case_sensitive_target:
+                        name = name.lower()
+                    name_ids.append((name, child_tid))
             name_ids.sort()
             last_name = None
             last_trans_id = None

=== modified file 'doc/developers/testing.txt'
--- a/doc/developers/testing.txt	2010-11-05 20:54:32 +0000
+++ b/doc/developers/testing.txt	2010-11-08 09:58:04 +0000
@@ -367,8 +367,9 @@
 The execution stops as soon as an expected output or an expected error is not
 matched.
 
-When no output is specified, any ouput from the command is accepted
-and execution continue.
+If output occurs and no output is expected, the execution stops and the
+test fails.  If unexpected output occurs on the standard error, then
+execution stops and the test fails.
 
 If an error occurs and no expected error is specified, the execution stops.
 
@@ -447,11 +448,11 @@
     def test_unshelve_keep(self):
         # some setup here
         script.run_script(self, '''
-            $ bzr add file
-            $ bzr shelve --all -m Foo
+            $ bzr add -q file
+            $ bzr shelve -q --all -m Foo
             $ bzr shelve --list
             1: Foo
-            $ bzr unshelve --keep
+            $ bzr unshelve -q --keep
             $ bzr shelve --list
             1: Foo
             $ cat file
@@ -471,6 +472,19 @@
             yes
             """)
 
+To avoid having to specify "-q" for all commands whose output is
+irrelevant, the run_script() method may be passed the keyword argument
+``null_output_matches_anything=True``.  For example::
+
+    def test_ignoring_null_output(self):
+        self.run_script("""
+            $ bzr init
+            $ bzr ci -m 'first revision' --unchanged
+            $ bzr log --line
+            1: ...
+            """, null_output_matches_anything=True)
+           
+
 Import tariff tests
 -------------------
 

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2010-11-06 17:09:42 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2010-11-08 11:01:20 +0000
@@ -37,6 +37,12 @@
 .. Fixes for situations where bzr would previously crash or give incorrect
    or undesirable results.
 
+* ``bzr resolve --take-other <file>`` will not crash anymore if ``<file>``
+  is involved in a text conflict (but the conflict is still not
+  resolved). (Vincent Ladeuil, #646961)
+
+* Report error if non-ASCII command option given. (Rory Yorke, #140563)
+
 Documentation
 *************
 
@@ -61,6 +67,15 @@
    suite.  This can include new facilities for writing tests, fixes to 
    spurious test failures and changes to the way things should be tested.
 
+* Add a null_output_matches_anything keyword argument with default False to
+  bzrlib.tests.script.ScriptRunner.run_script to specify that the command
+  output should not be checked (as opposed to expecting an empty output).
+  (Neil Martinsen-Burrell, #662509)
+
+* Blank output section in scriptrunner tests no longer match any output.
+  Instead, use '...' as a wildcard if you don't care about the output.
+  (Martin Pool, #637830)
+
 
 bzr 2.3b3
 #########
@@ -327,10 +342,6 @@
   involving the pycurl https test server fail otherwise when running
   selftest from an installed version. (Vincent Ladeuil, #651706)
 
-* Blank output section in scriptrunner tests no longer match any output.
-  Instead, use '...' as a wildcard if you don't care about the output.
-  (Martin Pool, #637830)
-
 * Fix tests that failed when run under ``LANG=C``.
   (Andrew Bennetts, #632387)
 



More information about the bazaar-commits mailing list