changeset 56:5185af4e649a

hg gfetch now works
author Scott Chacon <schacon@gmail.com>
date Wed, 29 Apr 2009 13:55:22 -0700
parents 4b1fa3d0fa8b
children eb05594fc3c8
files __init__.py git_handler.py
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/__init__.py
+++ b/__init__.py
@@ -73,10 +73,12 @@
     repo.ui.status(_("clearing out the git cache data\n"))
     git = GitHandler(repo, ui)
     git.clear()
-    
-def gfetch(ui, repo):
-    dest_repo.ui.status(_("pulling from git url\n"))
-           
+
+def gfetch(ui, repo, remote_name='origin'):
+    repo.ui.status(_("pulling from git url\n"))
+    git = GitHandler(repo, ui)
+    git.fetch(remote_name)
+
 commands.norepo += " gclone"
 cmdtable = {
   "gclone":
--- a/git_handler.py
+++ b/git_handler.py
@@ -113,8 +113,9 @@
     def fetch(self, remote_name):
         self.ui.status(_("fetching from : " + remote_name + "\n"))
         self.export_git_objects()
-        self.fetch_pack(remote_name)
-        self.import_git_objects(remote_name)
+        refs = self.fetch_pack(remote_name)
+        if refs:
+            self.import_git_objects(remote_name)
         self.save_map()
 
     def push(self, remote_name):
@@ -386,7 +387,11 @@
             refs = client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
             f.close()
             commit()
-            self.git.set_remote_refs(refs, remote_name)
+            if refs:
+                self.git.set_remote_refs(refs, remote_name)
+            else:
+                self.ui.status(_("nothing new on the server\n"))
+            return refs
         except:
             f.close()
             raise
@@ -422,8 +427,9 @@
 
         # import each of the commits, oldest first
         for csha in commits:
-            commit = convert_list[csha]
-            self.import_git_commit(commit)
+            if not self.map_hg_get(csha):
+                commit = convert_list[csha]
+                self.import_git_commit(commit)
 
         self.update_hg_bookmarks(remote_name)