Browse Source

Add really basic pull command.

Jelmer Vernooij 8 years ago
parent
commit
f41fe075fc
2 changed files with 18 additions and 1 deletions
  1. 13 0
      bin/dulwich
  2. 5 1
      dulwich/porcelain.py

+ 13 - 0
bin/dulwich

@@ -468,6 +468,18 @@ class cmd_pack_objects(Command):
             f.close()
 
 
+class cmd_pull(Command):
+
+    def run(self, args):
+        parser = optparse.OptionParser()
+        options, args = parser.parse_args(args)
+        try:
+            from_location = args[0]
+        except IndexError:
+            from_location = None
+        porcelain.pull('.', from_location)
+
+
 class cmd_remote_add(Command):
 
     def run(self, args):
@@ -536,6 +548,7 @@ commands = {
     "ls-remote": cmd_ls_remote,
     "ls-tree": cmd_ls_tree,
     "pack-objects": cmd_pack_objects,
+    "pull": cmd_pull,
     "receive-pack": cmd_receive_pack,
     "remote": cmd_remote,
     "repack": cmd_repack,

+ 5 - 1
dulwich/porcelain.py

@@ -692,7 +692,7 @@ def push(repo, remote_location, refspecs=None,
                             b"\n")
 
 
-def pull(repo, remote_location, refspecs=None,
+def pull(repo, remote_location=None, refspecs=None,
          outstream=default_bytes_out_stream, errstream=default_bytes_err_stream):
     """Pull from remote via dulwich.client
 
@@ -704,6 +704,10 @@ def pull(repo, remote_location, refspecs=None,
     """
     # Open the repo
     with open_repo_closing(repo) as r:
+        if remote_location is None:
+            # TODO(jelmer): Lookup 'remote' for current branch in config
+            raise NotImplementedError(
+                "looking up remote from branch config not supported yet")
         if refspecs is None:
             refspecs = [b"HEAD"]
         selected_refs = []