changeset 1293:9e85feb93984

wrappers: improve push performance by reusing the existing metadata Push operation for n commits regenerated SVNMeta class 2*n+1 times (one time at beginning, n times in push() loop, 1 time per each of n pulls). This operation is very costly when the revision map is big. This commit reuses this metadata every time when there is no rebase made between svn commits which leads to 1 metadata rebuild in optimistic case and n+1 metadata rebuilds in pessimistic case (rebase after every commit). To achieve this I added extra parameter to pull command to pass metadata to it. All unit tests are passing for this change.
author Mateusz Kwapich <mitrandir@fb.com>
date Fri, 12 Dec 2014 16:17:11 -0800
parents 7bbe120be193
children 9a722b5246df
files hgsubversion/wrappers.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -261,6 +261,8 @@ def push(repo, dest, force, revs):
 
                 # Don't trust the pre-rebase repo and context.
                 repo = getlocalpeer(ui, {}, meta.path)
+                meta = repo.svnmeta(svn.uuid, svn.subdir)
+                hashes = meta.revmap.hashes()
                 tip_ctx = repo[tip_ctx.node()]
                 for c in tip_ctx.descendants():
                     rebasesrc = c.extra().get('rebase_source')
@@ -289,10 +291,8 @@ def push(repo, dest, force, revs):
 
             # 5. Pull the latest changesets from subversion, which will
             # include the one we just committed (and possibly others).
-            r = pull(repo, dest, force=force)
+            r = pull(repo, dest, force=force, meta=meta)
             assert not r or r == 0
-            meta = repo.svnmeta(svn.uuid, svn.subdir)
-            hashes = meta.revmap.hashes()
 
             # 6. Move our tip to the latest pulled tip
             for c in tip_ctx.descendants():
@@ -379,7 +379,7 @@ def exchangepush(orig, repo, remote, for
     else:
         return orig(repo, remote, force, revs, newbranch, bookmarks=bookmarks)
 
-def pull(repo, source, heads=[], force=False):
+def pull(repo, source, heads=[], force=False, meta=None):
     """pull new revisions from Subversion"""
     assert source.capable('subversion')
     svn_url = source.svnurl
@@ -394,7 +394,8 @@ def pull(repo, source, heads=[], force=F
             repo.ui.note('fetching stupidly...\n')
 
         svn = source.svn
-        meta = repo.svnmeta(svn.uuid, svn.subdir)
+        if meta is None:
+            meta = repo.svnmeta(svn.uuid, svn.subdir)
 
         stopat_rev = util.parse_revnum(svn, checkout)