changeset 699:6dc550f2fa78

import_tags: don't import tags that don't have an hg commit equivalent The theme of this and upcoming patches is that relying on self.git.object_store to figure out which commits/tags/bookmarks to import is not great. This breaks if the git repo is manually put in place (as might be done in a server-based replication scenario), or if a partial fetch pulled too many commits in for whatever reason. Indeed we were just about always pulling an entire pack in, because listkeys for bookmarks currently calls fetch_pack without any filtering. (This is probably a bug and should be fixed, but this series doesn't do that.) Instead, rely on whether we actually imported the commit into Mercurial to determine whether to import the tag. This is clean, straightforward, and clearly correct. There is a whole series of bugs in this code that any test case for this would hit -- an upcoming patch will include a test for all these bugs at once.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 04 Mar 2014 14:26:30 -0800
parents a58ae693ab72
children a72816ade410
files hggit/git_handler.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -1099,14 +1099,16 @@
                     sha = None
                     if isinstance (obj, Commit): # lightweight
                         sha = self.map_hg_get(refs[k])
-                        self.tags[ref_name] = sha
+                        if sha is not None:
+                            self.tags[ref_name] = sha
                     elif isinstance (obj, Tag): # annotated
                         (obj_type, obj_sha) = obj.object
                         obj = self.git.get_object(obj_sha)
                         if isinstance (obj, Commit):
                             sha = self.map_hg_get(obj_sha)
                             # TODO: better handling for annotated tags
-                            self.tags[ref_name] = sha
+                            if sha is not None:
+                                self.tags[ref_name] = sha
         self.save_tags()
 
     def update_hg_bookmarks(self, refs):