Просмотр исходного кода

Add convenience function for opening the index associated with a repository.

Jelmer Vernooij 16 лет назад
Родитель
Сommit
7a1e640c8f
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      dulwich/repo.py

+ 10 - 0
dulwich/repo.py

@@ -143,6 +143,16 @@ class Repo(object):
     def controldir(self):
         return self._controldir
 
+    def index_path(self):
+        return os.path.join(self.controldir(), "index")
+
+    def open_index(self):
+        from dulwich.index import Index
+        return Index(self.index_path())
+
+    def has_index(self):
+        return os.path.exists(self.index_path())
+
     def find_missing_objects(self, determine_wants, graph_walker, progress):
         """Find the missing objects required for a set of revisions.