changeset 947:e1cb98792cf4

editor: do not reread all data upon branching Branch creation is a special case of add_directory(). Until now, it was handled by enumerating branch parent files and creating svncopy records which were later converted into open files or pushed into the RevisionData. By default, there is no reason to record anything, the files are the same than in the parent changeset. The tricky part is to correctly check the source is the parent revision. This change massively speeds up regular branching operations.
author Patrick Mezard <patrick@mezard.eu>
date Tue, 16 Oct 2012 08:47:01 +0200
parents 289f2c7752a8
children e2090fabc1a9
files hgsubversion/editor.py
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/editor.py
+++ b/hgsubversion/editor.py
@@ -428,18 +428,28 @@ class HgEditor(svnwrap.Editor):
             frompath = '%s/' % frompath
         else:
             frompath = ''
+
+        copyfromparent = False
+        if frompath == '' and br_path == '':
+            pnode = self.meta.get_parent_revision(
+                    self.current.rev.revnum, branch)
+            if pnode == new_hash:
+                # Data parent is topological parent and relative paths
+                # are the same, not need to do anything but restore
+                # files marked as deleted.
+                copyfromparent = True
+
         svncopies = {}
         copies = {}
         for f in fromctx:
             if not f.startswith(frompath):
                 continue
-            fctx = fromctx.filectx(f)
             dest = path + '/' + f[len(frompath):]
-            svncopies[dest] = CopiedFile(new_hash, f, None)
             if dest in self._deleted:
-                # Remove this once svn copies and edited files are
-                # clearly separated.
                 self._deleted.remove(dest)
+            if copyfromparent:
+                continue
+            svncopies[dest] = CopiedFile(new_hash, f, None)
             if branch == source_branch:
                 copies[dest] = f
         if copies: