changeset 400:6d4f3b6d2e08

respect references to tags that differ between git and .hgtags
author Adrian Sampson <adrian@radbox.org>
date Fri, 20 May 2011 22:41:43 -0700
parents 132fb69af782
children f17ca8ed620c e3b5b23f7236
files hggit/git_handler.py hggit/hgrepo.py
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -437,6 +437,20 @@
             self.import_git_commit(commit)
         util.progress(self.ui, 'importing', None, total=total, unit='commits')
 
+        # Remove any dangling tag references.
+        for name, rev in self.repo.tags().items():
+            if not rev in self.repo:
+                if hasattr(self, 'tagscache') and self.tagscache and \
+                        'name' in self.tagscache:
+                    # Mercurial 1.4 and earlier.
+                    del self.repo.tagscache[name]
+                elif hasattr(self, '_tags') and self._tags and \
+                        'name' in self._tags:
+                    # Mercurial 1.5 and later.
+                    del self.repo._tags[name]
+                if name in self.repo._tagtypes:
+                    del self.repo._tagtypes[name]
+
     def import_git_commit(self, commit):
         self.ui.debug(_("importing: %s\n") % commit.id)
 
--- a/hggit/hgrepo.py
+++ b/hggit/hgrepo.py
@@ -42,9 +42,6 @@
 
             git = GitHandler(self, self.ui)
             for tag, rev in git.tags.iteritems():
-                if tag in tags:
-                    continue
-
                 tags[tag] = bin(rev)
                 tagtypes[tag] = 'git'