# HG changeset patch # User Patrick Mezard # Date 1227242476 21600 # Node ID 9b5e528f67f8cbdf1d373380306535e44c15d55d # Parent 10dd34deac3bdb5e85cf0726c2e5c08789576cd6 Add a test to check EOLs are correctly converted diff --git a/tests/run.py b/tests/run.py --- a/tests/run.py +++ b/tests/run.py @@ -11,6 +11,7 @@ import test_fetch_truncated import test_push_command import test_push_renames import test_push_dirs +import test_push_eol import test_tags def suite(): @@ -21,6 +22,7 @@ def suite(): test_push_command.suite(), test_push_renames.suite(), test_push_dirs.suite(), + test_push_eol.suite(), test_tags.suite(), ]) diff --git a/tests/test_push_eol.py b/tests/test_push_eol.py new file mode 100644 --- /dev/null +++ b/tests/test_push_eol.py @@ -0,0 +1,42 @@ +import unittest + +import test_util + +class TestPushEol(test_util.TestBase): + def setUp(self): + test_util.TestBase.setUp(self) + test_util.load_fixture_and_fetch('emptyrepo.svndump', + self.repo_path, + self.wc_path) + + def _test_push_dirs(self, stupid): + changes = [ + # Root files with LF, CRLF and mixed EOL + ('lf', 'lf', 'a\nb\n\nc'), + ('crlf', 'crlf', 'a\r\nb\r\n\r\nc'), + ('mixed', 'mixed', 'a\r\nb\n\r\nc\nd'), + ] + self.commitchanges(changes) + self.pushrevisions(stupid) + self.assertchanges(changes, self.repo['tip']) + + changes = [ + # Update all files once, with same EOL + ('lf', 'lf', 'a\nb\n\nc\na\nb\n\nc'), + ('crlf', 'crlf', 'a\r\nb\r\n\r\nc\r\na\r\nb\r\n\r\nc'), + ('mixed', 'mixed', 'a\r\nb\n\r\nc\nd\r\na\r\nb\n\r\nc\nd'), + ] + self.commitchanges(changes) + self.pushrevisions(stupid) + self.assertchanges(changes, self.repo['tip']) + + def test_push_dirs(self): + self._test_push_dirs(False) + + def test_push_dirs_stupid(self): + self._test_push_dirs(True) + +def suite(): + all = [unittest.TestLoader().loadTestsFromTestCase(TestPushEol), + ] + return unittest.TestSuite(all) diff --git a/tests/test_push_renames.py b/tests/test_push_renames.py --- a/tests/test_push_renames.py +++ b/tests/test_push_renames.py @@ -21,19 +21,6 @@ class TestPushRenames(test_util.TestBase if ctx[f].renamed(): w('%s copied from %s\n' % (f, ctx[f].renamed()[0])) - def assertchanges(self, changes, ctx): - for source, dest, data in changes: - if dest is None: - self.assertTrue(source not in ctx) - else: - self.assertTrue(dest in ctx) - if data is None: - data = ctx.parents()[0][source].data() - self.assertEqual(data, ctx[dest].data()) - if dest != source: - copy = ctx[dest].renamed() - self.assertEqual(copy[0], source) - def test_push_renames(self): repo = self.repo diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -101,10 +101,10 @@ class TestBase(unittest.TestCase): def repo(self): return hg.repository(ui.ui(), self.wc_path) - def pushrevisions(self): + def pushrevisions(self, stupid=False): push_cmd.push_revisions_to_subversion( ui.ui(), repo=self.repo, hg_repo_path=self.wc_path, - svn_url=fileurl(self.repo_path)) + svn_url=fileurl(self.repo_path), stupid=stupid) def svnls(self, path, rev='HEAD'): path = self.repo_path + '/' + path @@ -169,3 +169,19 @@ class TestBase(unittest.TestCase): repo = self.repo hg.update(repo, nodeid) return nodeid + + def assertchanges(self, changes, ctx): + """Assert that all 'changes' (as in defined in commitchanged()) + went into ctx. + """ + for source, dest, data in changes: + if dest is None: + self.assertTrue(source not in ctx) + continue + self.assertTrue(dest in ctx) + if data is None: + data = ctx.parents()[0][source].data() + self.assertEqual(ctx[dest].data(), data) + if dest != source: + copy = ctx[dest].renamed() + self.assertEqual(copy[0], source)