view tests/test_helpers.py @ 1028:c4b25a903ad3

layouts: consistently return None for default branch This makes the single and standard layouts consistent in what they return for the default branch. Previously, single had returned 'default' now they both return None. In addition, this fixes a now-exposed bug in stupid's convert_revision logic. Specifically, when a file is replaced by another file within the same branch, we treated that as replacing the entire branch. this bug was previously hidden because meta.split_branch_path and meta.localname were inconsistent in what they returned for the single layout. meta.split-branch_path is used to maintain the set of known branches, where meta.localname is used to determine the branch for the path being replaced. This resulted in erroneously hitting the condition that skipped paths outside branches we know about when considering replace operations from svn.
author David Schleimer <dschleimer@fb.com>
date Wed, 05 Jun 2013 11:00:06 -0700
parents bfbfc9be3faa
children d741f536f23a
line wrap: on
line source

import os, sys, unittest

_rootdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, _rootdir)

from hgsubversion import editor

class TestHelpers(unittest.TestCase):
    def test_filestore(self):
        fs = editor.FileStore(2)
        fs.setfile('a', 'a')
        fs.setfile('b', 'b')
        self.assertEqual('a', fs._data.get('a'))
        self.assertEqual('b', fs._data.get('b'))

        fs.delfile('b')
        self.assertRaises(IOError, lambda: fs.getfile('b'))
        fs.setfile('bb', 'bb')
        self.assertTrue('bb' in fs._files)
        self.assertTrue('bb' not in fs._data)
        self.assertEqual('bb', fs.getfile('bb'))

        fs.delfile('bb')
        self.assertTrue('bb' not in fs._files)
        self.assertEqual([], os.listdir(fs._tempdir))
        self.assertRaises(IOError, lambda: fs.getfile('bb'))

        fs.setfile('bb', 'bb')
        self.assertEqual(1, len(os.listdir(fs._tempdir)))
        fs.popfile('bb')
        self.assertEqual([], os.listdir(fs._tempdir))
        self.assertRaises(editor.EditingError, lambda: fs.getfile('bb'))

def suite():
    return unittest.TestSuite([
        unittest.TestLoader().loadTestsFromTestCase(TestHelpers),
        ])