瀏覽代碼

Remove unnecessary indirection.

Jelmer Vernooij 15 年之前
父節點
當前提交
25197c670a
共有 1 個文件被更改,包括 11 次插入15 次删除
  1. 11 15
      dulwich/object_store.py

+ 11 - 15
dulwich/object_store.py

@@ -20,7 +20,6 @@
 """Git object store interfaces and implementation."""
 
 
-import errno
 import itertools
 import os
 import stat
@@ -312,19 +311,6 @@ class DiskObjectStore(BaseObjectStore):
           return ShaFile.from_file(path)
         return None
 
-    def _add_shafile(self, sha, o):
-        dir = os.path.join(self.path, sha[:2])
-        if not os.path.isdir(dir):
-            os.mkdir(dir)
-        path = os.path.join(dir, sha[2:])
-        if os.path.exists(path):
-            return # Already there, no need to write again
-        f = GitFile(path, 'wb')
-        try:
-            f.write(o.as_legacy_object())
-        finally:
-            f.close()
-
     def get_raw(self, name):
         """Obtain the raw text for an object.
         
@@ -430,7 +416,17 @@ class DiskObjectStore(BaseObjectStore):
 
         :param obj: Object to add
         """
-        self._add_shafile(obj.id, obj)
+        dir = os.path.join(self.path, obj.id[:2])
+        if not os.path.isdir(dir):
+            os.mkdir(dir)
+        path = os.path.join(dir, obj.id[2:])
+        if os.path.exists(path):
+            return # Already there, no need to write again
+        f = GitFile(path, 'wb')
+        try:
+            f.write(obj.as_legacy_object())
+        finally:
+            f.close()
 
     def add_objects(self, objects):
         """Add a set of objects to this object store.