Rev 4995: Warn instead of aborting on invalid values for append_revisions_only. in file:///home/vila/src/bzr/reviews/bzr.strict_append_revisions_only/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Feb 4 13:09:49 GMT 2010


At file:///home/vila/src/bzr/reviews/bzr.strict_append_revisions_only/

------------------------------------------------------------
revno: 4995
revision-id: v.ladeuil+lp at free.fr-20100204130948-vi4klo8hfwb5hfhk
parent: v.ladeuil+lp at free.fr-20100204104750-mhfzmxpxpd6wklgy
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: bzr.strict_append_revisions_only
timestamp: Thu 2010-02-04 14:09:48 +0100
message:
  Warn instead of aborting on invalid values for append_revisions_only.
  
  * bzrlib/tests/test_branch.py:
  (TestBranchOptions.test_invalid_append_revisions_only): Cath the
  warning instead of the exception.
  
  * bzrlib/branch.py:
  (BzrBranch8._get_append_revisions_only): Only warn if the option
  is invalid and default to False in that case for backward
  compatibility.
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2010-01-30 18:57:56 +0000
+++ b/bzrlib/branch.py	2010-02-04 13:09:48 +0000
@@ -33,6 +33,7 @@
         revision as _mod_revision,
         rio,
         symbol_versioning,
+        trace,
         transport,
         tsort,
         ui,
@@ -2698,7 +2699,9 @@
         append = ui.bool_from_string(value)
         if append is not None:
             return append
-        raise errors.BadOptionValue(name, value)
+        trace.warning('Value "%s" for append_revisions_only is not a boolean,'
+                      ' defaulting to False', value)
+        return False
 
     @needs_write_lock
     def generate_revision_history(self, revision_id, last_rev=None,

=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py	2010-02-04 10:47:50 +0000
+++ b/bzrlib/tests/test_branch.py	2010-02-04 13:09:48 +0000
@@ -517,8 +517,15 @@
     def test_invalid_append_revisions_only(self):
         """Ensure that BzrOptionValue raised on invalid settings"""
         self.config.set_user_option('append_revisions_only', 'invalid')
-        self.assertRaises(errors.BadOptionValue,
-                          self.branch._get_append_revisions_only)
+        warnings = []
+        def warning(*args):
+            warnings.append(args[0] % args[1:])
+        self.overrideAttr(trace, 'warning', warning)
+        self.check_aro_is(False, 'not-a-bool')
+        self.assertEqual(
+            'Value "not-a-bool" for append_revisions_only is not a boolean,'
+            ' defaulting to False',
+            warnings[0])
 
 
 class TestPullResult(TestCase):



More information about the bazaar-commits mailing list