Rev 5676: (vila) Merge 2.3 into trunk including fix for bug #710410 (Alexander in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Feb 22 14:51:36 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5676 [merge]
revision-id: pqm at pqm.ubuntu.com-20110222145131-azoy8b20eeo4utcq
parent: pqm at pqm.ubuntu.com-20110221221157-3dtpgotjz8ktfviu
parent: v.ladeuil+lp at free.fr-20110222135126-ot4q8uezqa03hp4n
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-02-22 14:51:31 +0000
message:
(vila) Merge 2.3 into trunk including fix for bug #710410 (Alexander
Belchenko)
modified:
bzrlib/tests/blackbox/test_config.py test_config.py-20100927150753-x6rf54uibd08r636-1
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
bzrlib/util/configobj/configobj.py configobj.py-20051018184548-06992a2246425e3e
doc/en/release-notes/bzr-2.2.txt bzr2.2.txt-20101008081016-21wd86gpfhllpue3-39
=== modified file 'bzrlib/tests/blackbox/test_config.py'
--- a/bzrlib/tests/blackbox/test_config.py 2010-11-09 16:26:07 +0000
+++ b/bzrlib/tests/blackbox/test_config.py 2011-02-22 12:59:14 +0000
@@ -76,22 +76,24 @@
def test_multiline_all_values(self):
self.bazaar_config.set_user_option('multiline', '1\n2\n')
- script.run_script(self, """\
+ # Fallout from bug 710410, the triple quotes have been toggled
+ script.run_script(self, '''\
$ bzr config -d tree
bazaar:
- multiline = '''1
+ multiline = """1
2
- '''
- """)
+ """
+ ''')
def test_multiline_value_only(self):
self.bazaar_config.set_user_option('multiline', '1\n2\n')
- script.run_script(self, """\
+ # Fallout from bug 710410, the triple quotes have been toggled
+ script.run_script(self, '''\
$ bzr config -d tree multiline
- '''1
+ """1
2
- '''
- """)
+ """
+ ''')
def test_list_all_values(self):
self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-01-20 04:44:14 +0000
+++ b/bzrlib/tests/test_config.py 2011-02-22 13:51:26 +0000
@@ -313,11 +313,37 @@
"""
co = config.ConfigObj()
co['test'] = 'foo#bar'
- lines = co.write()
+ outfile = StringIO()
+ co.write(outfile=outfile)
+ lines = outfile.getvalue().splitlines()
self.assertEqual(lines, ['test = "foo#bar"'])
co2 = config.ConfigObj(lines)
self.assertEqual(co2['test'], 'foo#bar')
+ def test_triple_quotes(self):
+ # Bug #710410: if the value string has triple quotes
+ # then ConfigObj versions up to 4.7.2 will quote them wrong
+ # and won't able to read them back
+ triple_quotes_value = '''spam
+""" that's my spam """
+eggs'''
+ co = config.ConfigObj()
+ co['test'] = triple_quotes_value
+ # While writing this test another bug in ConfigObj has been found:
+ # method co.write() without arguments produces list of lines
+ # one option per line, and multiline values are not split
+ # across multiple lines,
+ # and that breaks the parsing these lines back by ConfigObj.
+ # This issue only affects test, but it's better to avoid
+ # `co.write()` construct at all.
+ # [bialix 20110222] bug report sent to ConfigObj's author
+ outfile = StringIO()
+ co.write(outfile=outfile)
+ output = outfile.getvalue()
+ # now we're trying to read it back
+ co2 = config.ConfigObj(StringIO(output))
+ self.assertEquals(triple_quotes_value, co2['test'])
+
erroneous_config = """[section] # line 1
good=good # line 2
=== modified file 'bzrlib/util/configobj/configobj.py'
--- a/bzrlib/util/configobj/configobj.py 2009-04-17 22:24:54 +0000
+++ b/bzrlib/util/configobj/configobj.py 2011-02-22 09:17:40 +0000
@@ -1794,10 +1794,12 @@
def _get_triple_quote(self, value):
if (value.find('"""') != -1) and (value.find("'''") != -1):
raise ConfigObjError('Value "%s" cannot be safely quoted.' % value)
+ # upstream version (up to version 4.7.2) has the bug with incorrect quoting;
+ # fixed in our copy based on the suggestion of ConfigObj's author
if value.find('"""') == -1:
+ quot = tsquot
+ else:
quot = tdquot
- else:
- quot = tsquot
return quot
=== modified file 'doc/en/release-notes/bzr-2.2.txt'
--- a/doc/en/release-notes/bzr-2.2.txt 2011-02-09 08:24:25 +0000
+++ b/doc/en/release-notes/bzr-2.2.txt 2011-02-20 15:01:25 +0000
@@ -36,6 +36,10 @@
Internals
*********
+* Fixed bug in the bundled copy of ConfigObj with quoting of triple quotes
+ in the value string. Fix suggested by ConfigObj's author Michael Foord.
+ (Alexander Belchenko, #710410)
+
Testing
*******
More information about the bazaar-commits
mailing list