Rev 5570: Fix failing tests and refuse to interpolate dicts (we don't want to *support* dicts). in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Feb 17 17:51:13 UTC 2011


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

------------------------------------------------------------
revno: 5570
revision-id: v.ladeuil+lp at free.fr-20110217175113-vu30afh39laxgm34
parent: v.ladeuil+lp at free.fr-20110217165103-464ch6d59fg3zdhs
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: interpolate
timestamp: Thu 2011-02-17 18:51:13 +0100
message:
  Fix failing tests and refuse to interpolate dicts (we don't want to *support* dicts).
-------------- next part --------------
=== modified file 'bzrlib/bugtracker.py'
--- a/bzrlib/bugtracker.py	2010-09-25 00:42:22 +0000
+++ b/bzrlib/bugtracker.py	2011-02-17 17:51:13 +0000
@@ -231,7 +231,8 @@
 
 
 tracker_registry.register('gnome',
-    UniqueIntegerBugTracker('gnome', 'http://bugzilla.gnome.org/show_bug.cgi?id='))
+    UniqueIntegerBugTracker('gnome',
+                            'http://bugzilla.gnome.org/show_bug.cgi?id='))
 
 
 class URLParametrizedBugTracker(BugTracker):
@@ -246,7 +247,7 @@
     def get(self, abbreviation, branch):
         config = branch.get_config()
         url = config.get_user_option(
-            "%s_%s_url" % (self.type_name, abbreviation))
+            "%s_%s_url" % (self.type_name, abbreviation), interpolate=False)
         if url is None:
             return None
         self._base_url = url
@@ -261,9 +262,12 @@
         return urlutils.join(self._base_url, self._bug_area) + str(bug_id)
 
 
-class URLParametrizedIntegerBugTracker(IntegerBugTracker, URLParametrizedBugTracker):
-    """A type of bug tracker that can be found on a variety of different sites,
-    and thus needs to have the base URL configured, but only allows integer bug IDs.
+class URLParametrizedIntegerBugTracker(IntegerBugTracker,
+                                       URLParametrizedBugTracker):
+    """A type of bug tracker that  only allows integer bug IDs.
+
+    This can be found on a variety of different sites, and thus needs to have
+    the base URL configured.
 
     Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
     `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')

=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-02-17 14:40:41 +0000
+++ b/bzrlib/config.py	2011-02-17 17:51:13 +0000
@@ -326,6 +326,8 @@
         if interpolate:
             if isinstance(value, list):
                 value = self._interpolate_list(value)
+            elif isinstance(value, dict):
+                raise ValueError('Dicts do not support interpolation')
             else:
                 value = self._interpolate_string(value)
         return value

=== modified file 'bzrlib/tests/per_branch/test_config.py'
--- a/bzrlib/tests/per_branch/test_config.py	2010-05-13 16:31:08 +0000
+++ b/bzrlib/tests/per_branch/test_config.py	2011-02-17 17:51:13 +0000
@@ -33,6 +33,8 @@
         value_dict = {
             'ascii': 'abcd', u'unicode \N{WATCH}': u'foo \N{INTERROBANG}'}
         config.set_user_option('name', value_dict.copy())
-        self.assertEqual(value_dict, config.get_user_option('name'))
+        self.assertEqual(value_dict, config.get_user_option('name',
+                                                            interpolate=False))
+        self.assertRaises(ValueError, config.get_user_option, 'name')
 
 



More information about the bazaar-commits mailing list