Browse Source

Fix clone example. (#374)

Jelmer Vernooij 9 years ago
parent
commit
97bf01e5ea
2 changed files with 3 additions and 19 deletions
  1. 1 1
      dulwich/porcelain.py
  2. 2 18
      examples/clone.py

+ 1 - 1
dulwich/porcelain.py

@@ -238,7 +238,7 @@ def clone(source, target=None, bare=False, checkout=None, errstream=sys.stdout,
             progress=errstream.write)
         r[b"HEAD"] = remote_refs[b"HEAD"]
         if checkout:
-            errstream.write(b'Checking out HEAD')
+            errstream.write(b'Checking out HEAD\n')
             r.reset_index()
     except:
         r.close()

+ 2 - 18
examples/clone.py

@@ -6,8 +6,7 @@
 
 import sys
 from getopt import getopt
-from dulwich.repo import Repo
-from dulwich.client import get_transport_and_path
+from dulwich import porcelain
 
 opts, args = getopt(sys.argv, "", [])
 opts = dict(opts)
@@ -16,19 +15,4 @@ if len(args) < 2:
     print("usage: %s host:path path" % (args[0], ))
     sys.exit(1)
 
-# Connect to the remote repository
-client, host_path = get_transport_and_path(args[1])
-path = args[2]
-
-# Create the local repository
-r = Repo.init(path, mkdir=True)
-
-# Fetch the remote objects
-remote_refs = client.fetch(host_path, r,
-    determine_wants=r.object_store.determine_wants_all,
-    progress=sys.stdout.write)
-
-# Update the local head to point at the right object
-r["HEAD"] = remote_refs["HEAD"]
-
-r._build_tree()
+porcelain.clone(args[1], args[2])