changeset 688:7ca655e44d9a

git_handler: don't compute tags for each tag imported Previously we'd recompute the repo tags each time we'd consider importing a Git tag. This is O(n^2) in the number of tags and produced noticeable slowdowns in repos with large numbers of tags. To fix this, compute the tags just once. This is correct because the only case where we'd have issues is if multiple new Git tags with the same name were introduced, which can't happen because Git tags cannot share names. For a repository with over 200 tags, this causes a no-op hg pull to be sped up by around 0.5 seconds.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 24 Feb 2014 11:38:00 -0800
parents dd8733d21b96
children 1323058cc652
files hggit/git_handler.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -1074,6 +1074,7 @@
         keys = refs.keys()
         if not keys:
             return
+        repotags = self.repo.tags()
         for k in keys[:]:
             ref_name = k
             parts = k.split('/')
@@ -1085,7 +1086,7 @@
                     continue
                 if ref_name[-3:] == '^{}':
                     ref_name = ref_name[:-3]
-                if not ref_name in self.repo.tags():
+                if not ref_name in repotags:
                     obj = self.git.get_object(refs[k])
                     sha = None
                     if isinstance (obj, Commit): # lightweight