changeset 4062:516f883e3d79

convert-repo: handle packed git tags
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 06 Feb 2007 15:23:40 -0200
parents 40030c1b6bc6
children 5b1f663ef86d
files contrib/convert-repo
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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: