瀏覽代碼

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

Jelmer Vernooij 16 年之前
父節點
當前提交
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.