convert/svn: ignore composite tags
authorPatrick Mezard <pmezard@gmail.com>
Wed, 29 Apr 2009 21:48:59 +0200
changeset 8248 d093e57671ea
parent 8247 8846ebb844ac
child 8249 2c7c973c2abd
convert/svn: ignore composite tags Tools like cvs2svn generate tags made of files coming from different revisions from different branches. This is not supported by Mercurial, and it slows down the conversion a lot. Ignore them. See bacula@4082 for a sample.
hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Wed Apr 29 21:48:15 2009 +0200
+++ b/hgext/convert/subversion.py	Wed Apr 29 21:48:59 2009 +0200
@@ -460,11 +460,34 @@
                             tag[:2] = [tagpath, sourcerev]
                             break
                     else:
-                        pendings.append([source, sourcerev, dest.split('/')[-1]])
+                        pendings.append([source, sourcerev, dest])
+
+                # Filter out tags with children coming from different
+                # parts of the repository like:
+                # /tags/tag.1 (from /trunk:10)
+                # /tags/tag.1/foo (from /branches/foo:12)
+                # Here/tags/tag.1 discarded as well as its children.
+                # It happens with tools like cvs2svn. Such tags cannot
+                # be represented in mercurial.
+                addeds = dict((p, e.copyfrom_path) for p,e 
+                              in origpaths.iteritems() if e.action == 'A')
+                badroots = set()
+                for destroot in addeds:
+                    for source, sourcerev, dest in pendings:
+                        if (not dest.startswith(destroot + '/')
+                            or source.startswith(addeds[destroot] + '/')):
+                            continue
+                        badroots.add(destroot)
+                        break
+
+                for badroot in badroots:
+                    pendings = [p for p in pendings if p[2] != badroot 
+                                and not p[2].startswith(badroot + '/')]
 
                 # Tell tag renamings from tag creations
                 remainings = []
-                for source, sourcerev, tagname in pendings:
+                for source, sourcerev, dest in pendings:
+                    tagname = dest.split('/')[-1]
                     if source.startswith(srctagspath):
                         remainings.append([source, sourcerev, tagname])
                         continue