Fix imports, fix pack fetching when there are no changes.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 25 Dec 2008 00:54:56 +0000 (00:54 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 25 Dec 2008 00:54:56 +0000 (00:54 +0000)
bin/dul-fetch-pack
dulwich/repo.py
dulwich/server.py

index ee1be16b23bac5371655c16c7774c4414918df57..b1a3a0d9c4b321cb3f6d0e02ed741472ba625f41 100755 (executable)
 from dulwich.client import TCPGitClient, SimpleFetchGraphWalker
 from dulwich.repo import Repo
 import sys
+from getopt import getopt
 
-(host, path) = sys.argv[1].split(":", 1)
-client = TCPGitClient(host)
+opts, args = getopt(sys.argv[1:], "", ["all"])
+
+opts = dict(opts)
+
+if args == []:
+       print "Usage: dul-fetch-pack host:path"
+       sys.exit(1)
 
-all = True
+if not ":" in args[0]:
+       print "Usage: dul-fetch-pack host:path"
+       sys.exit(1)
+
+(host, path) = args[0].split(":", 1)
+client = TCPGitClient(host)
 
-if all:
+if "--all" in opts:
     determine_wants = lambda x: x.values()
 else:
     determine_wants = lambda x: sys.argv[1:]
index dba2a07e07e8fca5b3c3da473de23054648fff2c..d827f1db14640bb5c325a7e4dd32f84130ec9729 100644 (file)
@@ -70,7 +70,8 @@ class Repo(object):
     fd, path = tempfile.mkstemp(dir=self.pack_dir(), suffix=".pack")
     f = os.fdopen(fd, 'w')
     def commit():
-       self._move_in_pack(path)
+       if os.path.getsize(path) > 0:
+           self._move_in_pack(path)
     return f, commit
 
   def _move_in_pack(self, path):
index 4e3e8e880f1ee4aa7a9562e13c096a794a54c4c4..e3fcd6dbe853da779d0d1a4db74f26dc043432f7 100644 (file)
@@ -17,9 +17,9 @@
 # MA  02110-1301, USA.
 
 import SocketServer
-from dulwich.protocol import Protocol, TCP_GIT_PORT
+from dulwich.protocol import Protocol, TCP_GIT_PORT, extract_capabilities
 from dulwich.repo import Repo
-from dulwich.pack import PackData, Pack, write_pack_data, extract_capabilities
+from dulwich.pack import PackData, Pack, write_pack_data
 import os, sha, tempfile
 
 class Backend(object):