Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

Use ConfigFile in Repo.get_config().

Changeset a577926b6909

Parent 736ed9369128

by Jelmer Vernooij

Changes to 4 files · Browse files at a577926b6909 Showing diff from parent 736ed9369128 Diff from another changeset...

Change 1 of 1 Show Entire File dulwich/​config.py Stacked
 
20
21
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@@ -20,3 +20,19 @@
   """   + +class ConfigFile(object): + """A Git configuration file, like .git/config or ~/.gitconfig.""" + + def __init__(self): + """Create a new ConfigFile.""" + + def __eq__(self, other): + return isinstance(other, self.__class__) + + @classmethod + def from_file(cls, path): + ret = cls() + f = open(path, 'r') + # FIXME? + f.close()
Change 1 of 1 Show Entire File dulwich/​repo.py Stacked
 
883
884
885
886
887
888
 
 
 
 
 
 
 
889
890
891
 
883
884
885
 
 
 
886
887
888
889
890
891
892
893
894
895
@@ -883,9 +883,13 @@
  return self.commit(sha).parents     def get_config(self): - import ConfigParser - p = ConfigParser.RawConfigParser() - p.read(os.path.join(self._controldir, 'config')) + from dulwich.config import ConfigFile + try: + p = ConfigFile.from_file(os.path.join(self._controldir, 'config')) + except (IOError, OSError), e: + if e.errno == errno.ENOENT: + return ConfigFile() + raise   return dict((section, dict(p.items(section)))   for section in p.sections())  
 
18
19
20
 
 
21
 
 
 
 
 
 
 
 
 
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@@ -18,4 +18,14 @@
   """Tests for reading and writing configuraiton files."""   +from dulwich.config import ConfigFile +from dulwich.tests import TestCase   + +class ConfigFileTests(TestCase): + + def test_empty(self): + ConfigFile() + + def test_eq(self): + self.assertEquals(ConfigFile(), ConfigFile())
 
33
34
35
 
36
37
38
 
318
319
320
321
 
322
323
324
 
33
34
35
36
37
38
39
 
319
320
321
 
322
323
324
325
@@ -33,6 +33,7 @@
  tree_lookup_path,   )  from dulwich import objects +from dulwich.config import ConfigFile  from dulwich.repo import (   check_ref_format,   DictRefsContainer, @@ -318,7 +319,7 @@
    def test_get_config(self):   r = self._repo = open_repo('ooo_merge.git') - self.assertEquals({}, r.get_config()) + self.assertEquals(ConfigFile(), r.get_config())     def test_common_revisions(self):   """