Simplify the GitBackend further
authorJohn Carr <john.carr@unrouted.co.uk>
Tue, 30 Dec 2008 12:15:59 +0000 (12:15 +0000)
committerJohn Carr <john.carr@unrouted.co.uk>
Tue, 30 Dec 2008 12:15:59 +0000 (12:15 +0000)
dulwich/server.py

index 0abe3237ad57dae2670b37dcc7448f8f6b425e8a..003b3c43d455d8b25febf64275586aa4cb373875 100644 (file)
@@ -63,17 +63,9 @@ class GitBackend(Backend):
         self.get_refs = self.repo.get_refs
 
     def apply_pack(self, refs, read):
-        # store the incoming pack in the repository
-        fd, name = tempfile.mkstemp(suffix='.pack', prefix='pack-', dir=self.repo.pack_dir())
-        os.write(fd, read())
-        os.close(fd)
-
-        # strip '.pack' off our filename
-        basename = name[:-5]
-
-        # generate an index for it
-        pd = PackData(name)
-        pd.create_index_v2(basename+".idx")
+        fd, commit = self.repo.object_store.add_pack()
+        fd.write(read())
+        commit()
 
         for oldsha, sha, ref in refs:
             if ref == "0" * 40: