diff tests/test_rebuildmeta.py @ 890:78db88de9622

Partial metadata rebuilding For highly active subversion repositories, it can be excruciatingly slow to pull updates one at a time from subversion. One way around this is to setup another mercurial repo that pulls new commits from svn periodicly (say every 5 minutes). When you want to update your repository, you can pull commits from this mercurial repository via native mercurial protocols, which will be much faster than pulling directly from svn. Unfortunately, your metadata will be out of date after doing so. Highly active repositories also tend to be very large, which means that it takes a long time to rebuild your metadata from scratch. To address this, this adds support to do a partial rebuild on the metadata by processing only revisions that have been added to the repository after the last revision we processed. With the rev map 1k revisions (~2 days) behind tip updatemeta is dramatically faster than rebuild meta: $ hg --time svn updatemeta Time: real 0.570 secs (user 0.480+0.000 sys 0.060+0.000) $ hg --time svn rebuildmeta Time: real 129.160 secs (user 128.570+0.000 sys 0.320+0.000)
author David Schleimer <dschleimer@fb.com>
date Sat, 12 May 2012 07:28:23 -0700
parents 50c13e01c7e3
children 295a8b48e4e2
line wrap: on
line diff
--- a/tests/test_rebuildmeta.py
+++ b/tests/test_rebuildmeta.py
@@ -51,6 +51,43 @@ def _do_case(self, name, stupid, single)
         # remove the wrapper
         context.changectx.children = origchildren
 
+    self._run_assertions(name, stupid, single, src, dest, u)
+
+    wc3_path = self.wc_path + '_partial'
+    src, dest = test_util.hgclone(u,
+                                  self.wc_path,
+                                  wc3_path,
+                                  update=False,
+                                  rev=[0])
+
+    # insert a wrapper that prevents calling changectx.children()
+    extensions.wrapfunction(context.changectx, 'children', failfn)
+
+    try:
+        svncommands.rebuildmeta(u, dest,
+                                args=[test_util.fileurl(repo_path +
+                                                        subdir), ])
+    finally:
+        # remove the wrapper
+        context.changectx.children = origchildren
+
+    dest.pull(src)
+
+    # insert a wrapper that prevents calling changectx.children()
+    extensions.wrapfunction(context.changectx, 'children', failfn)
+    try:
+        svncommands.updatemeta(u, dest,
+                               args=[test_util.fileurl(repo_path +
+                                                        subdir), ])
+    finally:
+        # remove the wrapper
+        context.changectx.children = origchildren
+
+    self._run_assertions(name, stupid, single, src, dest, u)
+
+
+def _run_assertions(self, name, stupid, single, src, dest, u):
+
     self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
                     'no .hg/svn directory in the source!')
     self.assertTrue(os.path.isdir(os.path.join(src.path, 'svn')),
@@ -68,7 +105,7 @@ def _do_case(self, name, stupid, single)
             self.assertNotEqual(old, new,
                                 'rebuildmeta unexpected match on youngest rev!')
             continue
-        self.assertMultiLineEqual(old, new)
+        self.assertMultiLineEqual(old, new, tf + ' differs')
         self.assertEqual(src.branchtags(), dest.branchtags())
     srcbi = pickle.load(open(os.path.join(src.path, 'svn', 'branch_info')))
     destbi = pickle.load(open(os.path.join(dest.path, 'svn', 'branch_info')))
@@ -102,6 +139,7 @@ def buildmethod(case, name, stupid, sing
 
 
 attrs = {'_do_case': _do_case,
+         '_run_assertions': _run_assertions,
          }
 for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
     # this fixture results in an empty repository, don't use it