view tests/test_startrev.py @ 762:c31a1f92e1c6

svnexternals: preliminary support for subrepos based externals At this point, only pulling externals definitions into .hgsub and .hgsubstate is supported. One difference between subrepos and svn:externals is the former separate the source definition and target revision in two files, while svn:externals definitions contain both. To handle this, the svn:externals revision references is replaced with a {REV} placeholder and stored in .hgsub, prefixed with the external base directory separated with a ':', while the revision is extracted in .hgsubstate. For instance, the following external: -r3 ^/externals/proj2@2 deps/proj2 Becomes: (.hgsub) deps/proj2 = [hgsubversion] :-r{REV} ^/externals/proj2@2 deps/proj2 (.hgsubstate) 3 deps/proj2
author Patrick Mezard <pmezard@gmail.com>
date Thu, 25 Nov 2010 21:55:21 +0100
parents d101b39f6c51
children e9af7eba88db
line wrap: on
line source

import test_util

import os
import unittest

def _do_case(self, name, subdir, stupid):
    wc_base = self.wc_path
    self.wc_path = wc_base + '_full'
    headclone = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid,
                                             layout='single', startrev='HEAD')
    self.wc_path = wc_base + '_head'
    fullclone = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid,
                                             layout='single')

    fulltip = fullclone['tip']
    headtip = headclone['tip']
    # viewing diff's of lists of files is easier on the eyes
    self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(headtip))

    for f in fulltip:
        self.assertMultiLineEqual(fulltip[f].data(), headtip[f].data())

    self.assertNotEqual(len(fullclone), 0, "full clone shouldn't be empty")
    self.assertEqual(len(headclone), 1,
                     "shallow clone should have just one revision, not %d"
                     % len(headclone))

def buildmethod(case, name, subdir, stupid):
    m = lambda self: self._do_case(case, subdir.strip('/'), stupid)
    m.__name__ = name
    m.__doc__ = ('Test clone with startrev on %s%s with %s replay.' %
                 (case, subdir, (stupid and 'stupid') or 'real'))
    return m


# these fixtures contain no files at HEAD and would result in empty clones
nofiles = set([
    'binaryfiles.svndump',
    'emptyrepo.svndump',
])

# these fixtures contain no files in trunk at HEAD and would result in an empty
# shallow clone if cloning trunk, so we use another subdirectory
subdirmap = {
    'commit-to-tag.svndump': '/branches/magic',
    'pushexternals.svndump': '',
    'tag_name_same_as_branch.svndump': '/branches/magic',
}

attrs = {'_do_case': _do_case,
         }

for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
    if case in nofiles:
        continue

    subdir = test_util.subdir.get(case, '') + subdirmap.get(case, '/trunk')

    bname = 'test_' + case[:-len('.svndump')]
    attrs[bname] = buildmethod(case, bname, subdir, False)
    name = bname + '_stupid'
    attrs[name] = buildmethod(case, name, subdir, True)

StartRevTests = type('StartRevTests', (test_util.TestBase, ), attrs)


def suite():
    all = [unittest.TestLoader().loadTestsFromTestCase(StartRevTests),
          ]
    return unittest.TestSuite(all)