convert: restore previous svn transport parent correctly
authorPatrick Mezard <pmezard@gmail.com>
Fri, 25 Jul 2008 20:37:41 +0200
changeset 6847 9d6d1fdb7d72
parent 6842 e37fa751182a
child 6848 59c40c60d8d8
convert: restore previous svn transport parent correctly
hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Fri Jul 25 13:26:16 2008 +0200
+++ b/hgext/convert/subversion.py	Fri Jul 25 20:37:41 2008 +0200
@@ -188,6 +188,7 @@
             # Module is either empty or a repository path starting with
             # a slash and not ending with a slash.
             self.module = self.url[len(self.base):]
+            self.prevmodule = None
             self.rootmodule = self.module
             self.commits = {}
             self.paths = {}
@@ -478,9 +479,9 @@
         if not stop:
             stop = svn.ra.get_latest_revnum(self.ra)
         try:
-            self.reparent('')
+            prevmodule = self.reparent('')
             dirent = svn.ra.stat(self.ra, path.strip('/'), stop)
-            self.reparent(self.module)
+            self.reparent(prevmodule)
         except SubversionException:
             dirent = None
         if not dirent:
@@ -532,9 +533,17 @@
         return svn_rev in self.blacklist
 
     def reparent(self, module):
-        svn_url = self.base + module
-        self.ui.debug("reparent to %s\n" % svn_url.encode(self.encoding))
-        svn.ra.reparent(self.ra, svn_url.encode(self.encoding))
+        """Reparent the svn transport and return the previous parent."""
+        if self.prevmodule == module:
+            return module
+        svn_url = (self.base + module).encode(self.encoding)
+        prevmodule = self.prevmodule
+        if prevmodule is None:
+            prevmodule = ''
+        self.ui.debug("reparent to %s\n" % svn_url)
+        svn.ra.reparent(self.ra, svn_url)
+        self.prevmodule = module
+        return prevmodule
 
     def expandpaths(self, rev, paths, parents):
         entries = []
@@ -604,9 +613,9 @@
 
                 # We can avoid the reparent calls if the module has not changed
                 # but it probably does not worth the pain.
-                self.reparent('')
+                prevmodule = self.reparent('')
                 fromkind = svn.ra.check_path(self.ra, entrypath.strip('/'), fromrev)
-                self.reparent(self.module)
+                self.reparent(prevmodule)
 
                 if fromkind == svn.core.svn_node_file:   # a deleted file
                     entries.append(self.recode(entry))