More config fixes.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 27 Dec 2011 02:30:41 +0000 (03:30 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 27 Dec 2011 02:30:41 +0000 (03:30 +0100)
dulwich/config.py
dulwich/tests/test_config.py

index 61d86725aa7a631e782a355986a123386eda3d00..617e83ed648637af0c0ed763bf29aa86d95f3d09 100644 (file)
@@ -127,9 +127,15 @@ class ConfigFile(ConfigDict):
             line = line.lstrip()
             if setting is None:
                 if line[0] == "[" and line.rstrip()[-1] == "]":
-                    section = (line.strip()[1:-1], None)
+                    key = line.strip()
+                    pts = key[1:-1].split(" ", 1)
+                    if len(pts) == 2:
+                        if pts[1][0] != "\"" or pts[1][-1] != "\"":
+                            raise ValueError(pts[1])
+                        section = (pts[0], pts[1][1:-1])
+                    else:
+                        section = (pts[0], None)
                     ret._values[section[0]] = {section[1]: {}}
-                    # FIXME: Parse section
                 elif "=" in line:
                     setting, value = line.split("=", 1)
                     if section is None:
index fab70aa52df78985d43112c0c9c5e40b13649a2b..ac0235d8533409f9508135b1a04eddd857326ddc 100644 (file)
@@ -47,6 +47,11 @@ class ConfigFileTests(TestCase):
     def test_from_file_section(self):
         cf = self.from_file("[core]\nfoo = bar\n")
         self.assertEquals("bar", cf.get("core.foo"))
+        self.assertEquals("bar", cf.get("core.foo.foo"))
+
+    def test_from_file_subsection(self):
+        cf = self.from_file("[branch \"foo\"]\nfoo = bar\n")
+        self.assertEquals("bar", cf.get("branch.foo.foo"))
 
     def test_write_to_file_empty(self):
         c = ConfigFile()