convert-repo: handle packed git tags
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Tue, 06 Feb 2007 15:23:40 -0200
changeset 4062 516f883e3d79
parent 4061 40030c1b6bc6
child 4068 5b1f663ef86d
convert-repo: handle packed git tags
contrib/convert-repo
--- a/contrib/convert-repo	Sun Feb 04 16:08:56 2007 -0800
+++ b/contrib/convert-repo	Tue Feb 06 15:23:40 2007 -0200
@@ -359,14 +359,18 @@
 
     def gettags(self):
         tags = {}
-        for f in os.listdir(self.path + "/refs/tags"):
-            try:
-                h = file(self.path + "/refs/tags/" + f).read().strip()
-                c = self.catfile(h, "tag") # read the commit hash
-                h = c.splitlines()[0].split()[1]
-                tags[f] = h
-            except:
-                pass
+        fh = os.popen('git-ls-remote --tags "%s" 2>/dev/null' % self.path)
+        prefix = 'refs/tags/'
+        for line in fh:
+            line = line.strip()
+            if not line.endswith("^{}"):
+                continue
+            node, tag = line.split(None, 1)
+            if not tag.startswith(prefix):
+                continue
+            tag = tag[len(prefix):-3]
+            tags[tag] = node
+
         return tags
 
 class convert_mercurial: