view tests/test_single_dir_clone.py @ 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 6e1dbf6cbc92
children a36e87ae2380
line wrap: on
line source

import test_util

import errno
import shutil
import unittest

from mercurial import commands
from mercurial import context
from mercurial import hg
from mercurial import node
from mercurial import ui

from hgsubversion import compathacks

class TestSingleDirClone(test_util.TestBase):
    stupid_mode_tests = True

    def test_clone_single_dir_simple(self):
        repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
                                            layout='single',
                                            subdir='')
        self.assertEqual(compathacks.branchset(repo),
                         set(['default']))
        self.assertEqual(repo['tip'].manifest().keys(),
                         ['trunk/beta',
                          'tags/copied_tag/alpha',
                          'trunk/alpha',
                          'tags/copied_tag/beta',
                          'branches/branch_from_tag/alpha',
                          'tags/tag_r3/alpha',
                          'tags/tag_r3/beta',
                          'branches/branch_from_tag/beta'])

    def test_auto_detect_single(self):
        repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
                                            layout='auto')
        self.assertEqual(compathacks.branchset(repo),
                         set(['default', 'branch_from_tag']))
        oldmanifest = test_util.filtermanifest(repo['default'].manifest().keys())
        # remove standard layout
        shutil.rmtree(self.wc_path)
        # try again with subdir to get single dir clone
        repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
                                            layout='auto',
                                            subdir='trunk')
        self.assertEqual(compathacks.branchset(repo), set(['default', ]))
        self.assertEqual(repo['default'].manifest().keys(), oldmanifest)

    def test_clone_subdir_is_file_prefix(self):
        FIXTURE = 'subdir_is_file_prefix.svndump'
        repo = self._load_fixture_and_fetch(FIXTURE,
                                            layout='single',
                                            subdir=test_util.subdir[FIXTURE])
        self.assertEqual(compathacks.branchset(repo), set(['default']))
        self.assertEqual(repo['tip'].manifest().keys(), ['flaf.txt'])

    def test_externals_single(self):
        repo = self._load_fixture_and_fetch('externals.svndump',
                                            layout='single')
        for rev in repo:
            assert '.hgsvnexternals' not in repo[rev].manifest()
        return # TODO enable test when externals in single are fixed
        expect = """[.]
 -r2 ^/externals/project2@2 deps/project2
[subdir]
 ^/externals/project1 deps/project1
[subdir2]
 ^/externals/project1 deps/project1
"""
        test = 2
        self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect)

    def test_externals_single_whole_repo(self):
        # This is the test which demonstrates the brokenness of externals
        return # TODO enable test when externals in single are fixed
        repo = self._load_fixture_and_fetch('externals.svndump',
                                            layout='single',
                                            subdir='')
        for rev in repo:
            rc = repo[rev]
            if '.hgsvnexternals' in rc:
                extdata = rc['.hgsvnexternals'].data()
                assert '[.]' not in extdata
                print extdata
        expect = '' # Not honestly sure what this should be...
        test = 4
        self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect)