changeset 13:01f28d40cb6a

checks out the HEAD node from a clone
author Scott Chacon <schacon@gmail.com>
date Sun, 26 Apr 2009 15:51:05 -0700
parents 227b11d75844
children 36e94e805fa7
files TODO.txt __init__.py git_handler.py
diffstat 3 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/TODO.txt
+++ b/TODO.txt
@@ -2,11 +2,12 @@
 ===========
 
 * only try to import non-mapped commits
-* update/add bookmarks
-* checkout the tip
+* checkout the HEAD 
 * limit to HEAD branch? (gh-pages makes weird import)
   - possibly also add bookmarks on the same development line
 
+* strip or close branches that have been abandoned (?)
+
 * tag conversion
 
 FETCH
--- a/__init__.py
+++ b/__init__.py
@@ -46,7 +46,8 @@
     git.fetch('origin')
     
     # checkout the tip
-    hg.update(dest_repo, None)
+    node = git.remote_head('origin')
+    hg.update(dest_repo, node)
 
 def gpush(ui, repo):
     dest_repo.ui.status(_("pushing to git url\n"))
--- a/git_handler.py
+++ b/git_handler.py
@@ -47,6 +47,12 @@
     def remote_name_to_url(self, remote_name):
         return self._git_url
         
+    def remote_head(self, remote_name):
+        for head, sha in self.git.remote_refs(remote_name).iteritems():
+            if head == 'HEAD':
+                return self._map[sha]
+        return None
+        
     def fetch_pack(self, remote_name):
         git_url = self.remote_name_to_url(remote_name)
         client, path = self.get_transport_and_path(git_url)
@@ -93,13 +99,12 @@
             commit = convert_list[csha]
             self.import_git_commit(commit)
         
-        # TODO : update Hg bookmarks
+        # update Hg bookmarks
         bms = {}
         for head, sha in self.git.remote_refs(remote_name).iteritems():
             hgsha = hex_to_sha(self._map[sha])
-            bms[head] = hgsha
-            
-        print bms    
+            if not head == 'HEAD':
+                bms[remote_name + '/' + head] = hgsha            
         bookmarks.write(self.repo, bms)
 
     def import_git_commit(self, commit):