changeset 282:8655c071a15d

make sure no tag object are included in the DAG we build
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Wed, 24 Feb 2010 17:21:20 +0100
parents a14529b7b8f2
children 90458271e374
files hggit/git_handler.py tests/test-git-tags.out
diffstat 2 files changed, 18 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -354,14 +354,21 @@
         convert_list = {}
 
         # get a list of all the head shas
+        seenheads = set()
+        if refs is None:
+            refs = self.git.refs
         if refs:
-          for head, sha in refs.iteritems():
-              # refs contains all the refs in the server, not just the ones
-              # we are pulling
-              if sha in self.git.object_store:
-                  todo.append(sha)
-        else:
-            todo = self.git.refs.values()[:]
+            for sha in refs.itervalues():
+                # refs contains all the refs in the server, not just the ones
+                # we are pulling
+                if sha in self.git.object_store:
+                    obj = self.git.get_object(sha)
+                    while isinstance(obj, Tag):
+                        obj_type, sha = obj.get_object()
+                        obj = self.git.get_object(sha)
+                    if isinstance (obj, Commit) and sha not in seenheads:
+                        seenheads.add(sha)
+                        todo.append(sha)
 
         # traverse the heads getting a list of all the unique commits
         while todo:
@@ -371,15 +378,9 @@
                 continue
             done.add(sha)
             obj = self.git.get_object(sha)
-            if isinstance (obj, Commit):
-                convert_list[sha] = obj
-                todo.extend([p for p in obj.parents if p not in done])
-            if isinstance(obj, Tag):
-                (obj_type, obj_sha) = obj.get_object()
-                obj = self.git.get_object(obj_sha)
-                if isinstance (obj, Commit):
-                    convert_list[sha] = obj
-                    todo.extend([p for p in obj.parents if p not in done])
+            assert isinstance(obj, Commit)
+            convert_list[sha] = obj
+            todo.extend([p for p in obj.parents if p not in done])
 
         # sort the commits
         commits = toposort.TopoSort(convert_list).items()
--- a/tests/test-git-tags.out
+++ b/tests/test-git-tags.out
@@ -5,7 +5,7 @@
 Compressing objects:  25% (1/4)   
Compressing objects:  50% (2/4)   
Compressing objects:  75% (3/4)   
Compressing objects: 100% (4/4)   
Compressing objects: 100% (4/4), done.
 Total 7 (delta 0), reused 0 (delta 0)
 importing Git objects into Hg
-at: 0/3
+at: 0/2
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:99dcc15b7b07
 |  tag:         default/master