view tests/test_single_dir_clone.py @ 1512:6d0fe7ce9898

commands: fix command option registering A recent patch introduced svnopts as a way of sharing the svn command options between the old and the new way of registering a command. It turns out 'svnopts' was already used further up in the module to define the flags that should be added to *all* Mercurial commands. So our definition of it here cause us to add all of these options to all Mercurial commands. This was caught because it changes --rev to be '' instead of [], which breaks a number of assumptions in the other commands. Given that none of the subversion tests are command line tests, I'm not sure how to test this. It was caught in other extensions tests. (grafted from 3b1334407783a4379fd515e2ed9acc61e3f175ff) (grafted from 6db63ead5556f2bf72e423ca8c6df08ea3a5b009)
author Durham Goode <durham@fb.com>
date Wed, 24 May 2017 15:07:00 -0700
parents a36e87ae2380
children d55c9d0ba350
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(sorted(repo['tip'].manifest().keys()),
                         ['branches/branch_from_tag/alpha',
                          'branches/branch_from_tag/beta',
                          'tags/copied_tag/alpha',
                          'tags/copied_tag/beta',
                          'tags/tag_r3/alpha',
                          'tags/tag_r3/beta',
                          'trunk/alpha',
                          'trunk/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)