diff options
author | Oleksandr Usov <oleksandr.usov@tibra.com> | 2011-10-20 19:14:27 +0100 |
---|---|---|
committer | Oleksandr Usov <oleksandr.usov@tibra.com> | 2011-10-20 19:14:27 +0100 |
commit | 415445fe306084a2ea0c1f5a204646e8728c2e76 (patch) | |
tree | bb2e85052cf4d47f7fe579fbb684e0df137f138f /fastimport/tests/test_filter_processor.py | |
parent | 5f76c2ac819b967baf1a40867acf239e425d8ebe (diff) | |
download | python-fastimport-415445fe306084a2ea0c1f5a204646e8728c2e76.tar.gz |
Add preserve_all_history flag to filter_processor and tests for it
Diffstat (limited to 'fastimport/tests/test_filter_processor.py')
-rw-r--r-- | fastimport/tests/test_filter_processor.py | 122 |
1 files changed, 120 insertions, 2 deletions
diff --git a/fastimport/tests/test_filter_processor.py b/fastimport/tests/test_filter_processor.py index ad040d7..4472424 100644 --- a/fastimport/tests/test_filter_processor.py +++ b/fastimport/tests/test_filter_processor.py @@ -102,7 +102,6 @@ M 644 :3 doc/README.txt M 644 :4 doc/index.txt """ - class TestCaseWithFiltering(TestCase): def assertFiltering(self, input, params, expected): @@ -116,7 +115,6 @@ class TestCaseWithFiltering(TestCase): out = outf.getvalue() self.assertEquals(expected, out) - class TestNoFiltering(TestCaseWithFiltering): def test_params_not_given(self): @@ -876,3 +874,123 @@ reset refs/heads/foo reset refs/heads/bar from :101 """) + + +# A sample input stream containing empty commit +_SAMPLE_EMPTY_COMMIT = \ +"""blob +mark :1 +data 4 +foo +commit refs/heads/master +mark :2 +committer Joe <joe@example.com> 1234567890 +1000 +data 14 +Initial import +M 644 :1 COPYING +commit refs/heads/master +mark :3 +committer Joe <joe@example.com> 1234567890 +1000 +data 12 +empty commit +""" + +# A sample input stream containing unresolved from and merge references +_SAMPLE_FROM_MERGE_COMMIT = \ +"""blob +mark :1 +data 4 +foo +commit refs/heads/master +mark :3 +committer Joe <joe@example.com> 1234567890 +1000 +data 6 +import +M 644 :1 COPYING +blob +mark :2 +data 4 +bar +commit refs/heads/master +mark :4 +committer Joe <joe@example.com> 1234567890 +1000 +data 19 +unknown from commit +from :999 +M 644 :2 DATA +blob +mark :99 +data 4 +bar +commit refs/heads/master +mark :5 +committer Joe <joe@example.com> 1234567890 +1000 +data 12 +merge commit +from :3 +merge :4 +merge :1001 +M 644 :99 DATA2 +""" + +class TestPreserveHistoryFlag(TestCaseWithFiltering): + + def test_squashing_empty_commits(self): + params = {'include_paths': None, 'exclude_paths': None} + self.assertFiltering(_SAMPLE_EMPTY_COMMIT, params, \ +"""blob +mark :1 +data 4 +foo +commit refs/heads/master +mark :2 +committer Joe <joe@example.com> 1234567890 +1000 +data 14 +Initial import +M 644 :1 COPYING +""") + + def test_keep_empty_commits(self): + params = {'include_paths': None, 'exclude_paths': None, 'preserve_all_history': True} + self.assertFiltering(_SAMPLE_EMPTY_COMMIT, params, _SAMPLE_EMPTY_COMMIT) + + def test_squash_unresolved_references(self): + params = {'include_paths': None, 'exclude_paths': None} + self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \ +"""blob +mark :1 +data 4 +foo +commit refs/heads/master +mark :3 +committer Joe <joe@example.com> 1234567890 +1000 +data 6 +import +M 644 :1 COPYING +blob +mark :2 +data 4 +bar +commit refs/heads/master +mark :4 +committer Joe <joe@example.com> 1234567890 +1000 +data 19 +unknown from commit +M 644 :2 DATA +blob +mark :99 +data 4 +bar +commit refs/heads/master +mark :5 +committer Joe <joe@example.com> 1234567890 +1000 +data 12 +merge commit +from :3 +merge :4 +M 644 :99 DATA2 +""") + + def test_keep_unresolved_from_and_merge(self): + params = {'include_paths': None, 'exclude_paths': None, 'preserve_all_history': True} + self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, _SAMPLE_FROM_MERGE_COMMIT) |