changeset 11194:6798536454e6 stable

convert/svn: remove useless try/catch While the try/catch was reintroduced in 2f0f9528e77b, it was made useless by the tags/ existence check in getheads().
author Patrick Mezard <pmezard@gmail.com>
date Wed, 19 May 2010 22:04:41 +0200
parents b5c0f6a11430
children 46bb49134498
files hgext/convert/subversion.py tests/svn/branches.svndump tests/svn/svndump-branches.sh
diffstat 3 files changed, 77 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/subversion.py	Mon May 17 21:16:35 2010 +0200
+++ b/hgext/convert/subversion.py	Wed May 19 22:04:41 2010 +0200
@@ -448,79 +448,76 @@
         pendings = []
         tagspath = self.tags
         start = svn.ra.get_latest_revnum(self.ra)
-        try:
-            for entry in self._getlog([self.tags], start, self.startrev):
-                origpaths, revnum, author, date, message = entry
-                copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p, e
-                          in origpaths.iteritems() if e.copyfrom_path]
-                # Apply moves/copies from more specific to general
-                copies.sort(reverse=True)
+        for entry in self._getlog([self.tags], start, self.startrev):
+            origpaths, revnum, author, date, message = entry
+            copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p, e
+                      in origpaths.iteritems() if e.copyfrom_path]
+            # Apply moves/copies from more specific to general
+            copies.sort(reverse=True)
 
-                srctagspath = tagspath
-                if copies and copies[-1][2] == tagspath:
-                    # Track tags directory moves
-                    srctagspath = copies.pop()[0]
+            srctagspath = tagspath
+            if copies and copies[-1][2] == tagspath:
+                # Track tags directory moves
+                srctagspath = copies.pop()[0]
 
-                for source, sourcerev, dest in copies:
-                    if not dest.startswith(tagspath + '/'):
-                        continue
-                    for tag in pendings:
-                        if tag[0].startswith(dest):
-                            tagpath = source + tag[0][len(dest):]
-                            tag[:2] = [tagpath, sourcerev]
-                            break
-                    else:
-                        pendings.append([source, sourcerev, dest])
+            for source, sourcerev, dest in copies:
+                if not dest.startswith(tagspath + '/'):
+                    continue
+                for tag in pendings:
+                    if tag[0].startswith(dest):
+                        tagpath = source + tag[0][len(dest):]
+                        tag[:2] = [tagpath, sourcerev]
+                        break
+                else:
+                    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' and e.copyfrom_path)
-                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
+            # 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' and e.copyfrom_path)
+            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 + '/')]
+            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, dest in pendings:
-                    tagname = dest.split('/')[-1]
-                    if source.startswith(srctagspath):
-                        remainings.append([source, sourcerev, tagname])
-                        continue
-                    if tagname in tags:
-                        # Keep the latest tag value
-                        continue
-                    # From revision may be fake, get one with changes
-                    try:
-                        tagid = self.latest(source, sourcerev)
-                        if tagid and tagname not in tags:
-                            tags[tagname] = tagid
-                    except SvnPathNotFound:
-                        # It happens when we are following directories
-                        # we assumed were copied with their parents
-                        # but were really created in the tag
-                        # directory.
-                        pass
-                pendings = remainings
-                tagspath = srctagspath
+            # Tell tag renamings from tag creations
+            remainings = []
+            for source, sourcerev, dest in pendings:
+                tagname = dest.split('/')[-1]
+                if source.startswith(srctagspath):
+                    remainings.append([source, sourcerev, tagname])
+                    continue
+                if tagname in tags:
+                    # Keep the latest tag value
+                    continue
+                # From revision may be fake, get one with changes
+                try:
+                    tagid = self.latest(source, sourcerev)
+                    if tagid and tagname not in tags:
+                        tags[tagname] = tagid
+                except SvnPathNotFound:
+                    # It happens when we are following directories
+                    # we assumed were copied with their parents
+                    # but were really created in the tag
+                    # directory.
+                    pass
+            pendings = remainings
+            tagspath = srctagspath
 
-        except SubversionException:
-            self.ui.note(_('no tags found at revision %d\n') % start)
         return tags
 
     def converted(self, rev, destrev):
--- a/tests/svn/branches.svndump	Mon May 17 21:16:35 2010 +0200
+++ b/tests/svn/branches.svndump	Wed May 19 22:04:41 2010 +0200
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: 3c3c228a-b3dd-467c-a766-896f4b7cd0af
+UUID: 9ccdebd5-40da-43b4-a9c9-c2857851ccaf
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:38:53.023457Z
+2010-05-19T19:36:21.767874Z
 PROPS-END
 
 Revision-number: 1
@@ -27,7 +27,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:38:53.111986Z
+2010-05-19T19:36:21.795557Z
 PROPS-END
 
 Node-path: branches
@@ -39,15 +39,6 @@
 PROPS-END
 
 
-Node-path: tags
-Node-kind: dir
-Node-action: add
-Prop-content-length: 10
-Content-length: 10
-
-PROPS-END
-
-
 Node-path: trunk
 Node-kind: dir
 Node-action: add
@@ -72,7 +63,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:38:54.182594Z
+2010-05-19T19:36:22.069417Z
 PROPS-END
 
 Node-path: branches/notinbranch
@@ -164,7 +155,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:38:57.166484Z
+2010-05-19T19:36:25.067407Z
 PROPS-END
 
 Node-path: branches/old
@@ -197,7 +188,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:38:59.084420Z
+2010-05-19T19:36:27.042834Z
 PROPS-END
 
 Node-path: trunk/a
@@ -227,7 +218,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:39:00.093201Z
+2010-05-19T19:36:28.045031Z
 PROPS-END
 
 Node-path: branches/old/b
@@ -257,7 +248,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:39:02.078633Z
+2010-05-19T19:36:30.049884Z
 PROPS-END
 
 Node-path: branches/old/c
@@ -295,7 +286,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:39:03.065537Z
+2010-05-19T19:36:31.044711Z
 PROPS-END
 
 Node-path: branches/old/b
@@ -326,7 +317,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:39:06.070275Z
+2010-05-19T19:36:34.043552Z
 PROPS-END
 
 Node-path: branches/old2
@@ -355,7 +346,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:39:08.082539Z
+2010-05-19T19:36:36.042680Z
 PROPS-END
 
 Node-path: branches/old
@@ -384,7 +375,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:39:09.073290Z
+2010-05-19T19:36:37.043714Z
 PROPS-END
 
 Node-path: trunk/a
@@ -413,7 +404,7 @@
 K 8
 svn:date
 V 27
-2009-06-21T12:39:11.070264Z
+2010-05-19T19:36:39.044703Z
 PROPS-END
 
 Node-path: branches/old3
--- a/tests/svn/svndump-branches.sh	Mon May 17 21:16:35 2010 +0200
+++ b/tests/svn/svndump-branches.sh	Wed May 19 22:04:41 2010 +0200
@@ -10,7 +10,6 @@
 cd project-orig
 mkdir trunk
 mkdir branches
-mkdir tags
 cd ..
 
 svnadmin create svn-repo