fix uses of old api (Repo.{set,remove}_ref ObjectStore.add_pack)
authorAbderrahim Kitouni <a.kitouni@gmail.com>
Fri, 17 Jul 2009 20:29:08 +0000 (21:29 +0100)
committerAbderrahim Kitouni <a.kitouni@gmail.com>
Fri, 17 Jul 2009 20:29:08 +0000 (21:29 +0100)
bin/dulwich
dulwich/server.py

index 1a971a79e33185703a86219f1b68fea253af31a4..20582f28ca000926f4b952b41fd69c936a0f2463 100755 (executable)
@@ -43,12 +43,9 @@ def cmd_fetch_pack(args):
        graphwalker = r.get_graph_walker()
        f, commit = r.object_store.add_pack()
        try:
-               client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
-               f.close()
+            client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
+        finally:
                commit()
-       except:
-               f.close()
-               raise
 
 
 def cmd_log(args):
index 244393a7328ccc8dfe0e794ea330a2cb97e3f633..15e9116c7dc4d262b75814612c59f9d087bf33b1 100644 (file)
@@ -77,16 +77,17 @@ class GitBackend(Backend):
         self.get_refs = self.repo.get_refs
 
     def apply_pack(self, refs, read):
-        fd, commit = self.repo.object_store.add_thin_pack()
-        fd.write(read())
-        fd.close()
-        commit()
+        f, commit = self.repo.object_store.add_thin_pack()
+        try:
+            f.write(read())
+        finally:
+            commit()
 
         for oldsha, sha, ref in refs:
             if ref == "0" * 40:
-                self.repo.remove_ref(ref)
+                del self.repo.refs[ref]
             else:
-                self.repo.set_ref(ref, sha)
+                self.repo.refs[ref] = sha
 
         print "pack applied"