浏览代码

Don't 'want' refs we already have.

Jelmer Vernooij 16 年之前
父节点
当前提交
30f2f62d80
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 2 2
      bin/dul-fetch-pack
  2. 8 0
      dulwich/repo.py

+ 2 - 2
bin/dul-fetch-pack

@@ -38,9 +38,9 @@ if not ":" in args[0]:
 client = TCPGitClient(host)
 
 if "--all" in opts:
-    determine_wants = lambda x: x.values()
+    determine_wants = lambda x: [y for y in x.values() if not y in r.object_store]
 else:
-    determine_wants = lambda x: args
+    determine_wants = lambda x: [y for y in args if not y in r.object_store]
 
 r = Repo(".")
 

+ 8 - 0
dulwich/repo.py

@@ -209,6 +209,14 @@ class ObjectStore(object):
     def pack_dir(self):
         return os.path.join(self.path, PACKDIR)
 
+    def __contains__(self, sha):
+        # TODO: This can be more efficient
+        try:
+            self[sha]
+            return True
+        except KeyError:
+            return False
+
     @property
     def packs(self):
         if self._packs is None: