view tests/test_fetch_truncated.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 20e73b5ab6f7
children d741f536f23a
line wrap: on
line source

import test_util

import unittest

from mercurial import commands
from mercurial import hg

class TestFetchTruncatedHistory(test_util.TestBase):
    def test_truncated_history(self, stupid=False):
        # Test repository does not follow the usual layout
        repo_path = self.load_svndump('truncatedhistory.svndump')
        svn_url = test_util.fileurl(repo_path + '/project2')
        commands.clone(self.ui(stupid), svn_url, self.wc_path, noupdate=True)
        repo = hg.repository(self.ui(stupid), self.wc_path)

        # We are converting /project2/trunk coming from:
        #
        # Changed paths:
        #     D /project1
        #     A /project2/trunk (from /project1:2)
        #
        # Here a full fetch should be performed since we are starting
        # the conversion on an already filled branch.
        tip = repo['tip']
        files = tip.manifest().keys()
        files.sort()
        self.assertEqual(files, ['a', 'b'])
        self.assertEqual(repo['tip']['a'].data(), 'a\n')

    def test_truncated_history_stupid(self):
        self.test_truncated_history(True)

def suite():
    all_tests = [unittest.TestLoader().loadTestsFromTestCase(TestFetchTruncatedHistory),
          ]
    return unittest.TestSuite(all_tests)