소스 검색

Support MemoryRepo.get_config.

Jelmer Vernooij 12 년 전
부모
커밋
527a2bd585
2개의 변경된 파일27개의 추가작업 그리고 10개의 파일을 삭제
  1. 2 0
      NEWS
  2. 25 10
      dulwich/repo.py

+ 2 - 0
NEWS

@@ -33,6 +33,8 @@
   * Support cloning repositories without HEAD set.
     (D-Key, Jelmer Vernooij, issue #69)
 
+  * Support ``MemoryRepo.get_config``. (Jelmer Vernooij)
+
 0.8.5	2012-03-29
 
  BUG FIXES

+ 25 - 10
dulwich/repo.py

@@ -967,16 +967,7 @@ class BaseRepo(object):
 
         :return: `ConfigFile` object for the ``.git/config`` file.
         """
-        from dulwich.config import ConfigFile
-        path = os.path.join(self._controldir, 'config')
-        try:
-            return ConfigFile.from_path(path)
-        except (IOError, OSError), e:
-            if e.errno != errno.ENOENT:
-                raise
-            ret = ConfigFile()
-            ret.path = path
-            return ret
+        raise NotImplementedError(self.get_config)
 
     def get_config_stack(self):
         """Return a config stack for this repository.
@@ -1395,6 +1386,22 @@ class Repo(BaseRepo):
 
         return target
 
+    def get_config(self):
+        """Retrieve the config object.
+
+        :return: `ConfigFile` object for the ``.git/config`` file.
+        """
+        from dulwich.config import ConfigFile
+        path = os.path.join(self._controldir, 'config')
+        try:
+            return ConfigFile.from_path(path)
+        except (IOError, OSError), e:
+            if e.errno != errno.ENOENT:
+                raise
+            ret = ConfigFile()
+            ret.path = path
+            return ret
+
     def __repr__(self):
         return "<Repo at %r>" % self.path
 
@@ -1479,6 +1486,14 @@ class MemoryRepo(BaseRepo):
         """
         raise NoIndexPresent()
 
+    def get_config(self):
+        """Retrieve the config object.
+
+        :return: `ConfigFile` object.
+        """
+        from dulwich.config import ConfigFile
+        return ConfigFile()
+
     @classmethod
     def init_bare(cls, objects, refs):
         """Create a new bare repository in memory.