Simplify clone code.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 11 Mar 2010 17:09:56 +0000 (18:09 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 11 Mar 2010 17:09:56 +0000 (18:09 +0100)
bin/dulwich
dulwich/client.py

index 441f43ac311ded8c006d4fb0cddf1b65884ca193..8ebc5fce7c80cbecb978d80fb7d0e372f3cdc9dd 100755 (executable)
@@ -152,13 +152,11 @@ def cmd_clone(args):
 
     if not os.path.exists(path):
         os.mkdir(path)
-    Repo.init(path)
-    r = Repo(path)
-    graphwalker = r.get_graph_walker()
-    f, commit = r.object_store.add_pack()
-    client.fetch_pack(host_path, r.object_store.determine_wants_all, 
-                      graphwalker, f.write, sys.stdout.write)
-    commit()
+    r = Repo.init(path)
+    remote_refs = client.fetch(host_path, r,
+        determine_wants=r.object_store.determine_wants_all,
+        progress=sys.stdout.write)
+    r["HEAD"] = remote_refs["HEAD"]
 
 
 def cmd_commit(args):
index eeeeeb580b10d47db4e325319f2c8b061bd8e1e1..e829c0f0eb43d79ee596bdfe3467d73b187c8477 100644 (file)
@@ -139,8 +139,8 @@ class GitClient(object):
             determine_wants = target.object_store.determine_wants_all
         f, commit = target.object_store.add_pack()
         try:
-            return self.fetch_pack(path, determine_wants, target.graph_walker, 
-                                   f.write, progress)
+            return self.fetch_pack(path, determine_wants, 
+                target.get_graph_walker(), f.write, progress)
         finally:
             commit()