diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2011-10-22 14:47:22 -0700 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2011-10-22 14:47:22 -0700 |
commit | 0d0a934996871e5245564ba06d4fc3b9b2f5964c (patch) | |
tree | a430987e6a05a3628ed1f60892f815f964717350 /fastimport/tests | |
parent | e92e99dcdad632d0676b1e6146cc557a13054aa9 (diff) | |
parent | ab6fdb93582f85ccf482d6d1bfefad7a54384e2f (diff) | |
download | python-fastimport-0d0a934996871e5245564ba06d4fc3b9b2f5964c.tar.gz |
Merge support for squash_empty_commit argument to FilterProcessor.
Diffstat (limited to 'fastimport/tests')
-rw-r--r-- | fastimport/tests/test_filter_processor.py | 233 |
1 files changed, 231 insertions, 2 deletions
diff --git a/fastimport/tests/test_filter_processor.py b/fastimport/tests/test_filter_processor.py index c3ae21e..d6508f2 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): @@ -877,3 +875,234 @@ 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/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 data/DATA2 +""" + +class TestSquashEmptyCommitsFlag(TestCaseWithFiltering): + + def test_squash_empty_commit(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_commit(self): + params = {'include_paths': None, 'exclude_paths': None, 'squash_empty_commits': False} + 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 +from :999 +M 644 :2 data/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 data/DATA2 +""") + + def test_keep_unresolved_from_and_merge(self): + params = {'include_paths': None, 'exclude_paths': None, 'squash_empty_commits': False} + self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, _SAMPLE_FROM_MERGE_COMMIT) + + def test_with_excludes(self): + params = {'include_paths': None, + 'exclude_paths': ['data/DATA'], + 'squash_empty_commits': False} + 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 +commit refs/heads/master +mark :4 +committer Joe <joe@example.com> 1234567890 +1000 +data 19 +unknown from commit +from :999 +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 data/DATA2 +""") + + def test_with_file_includes(self): + params = {'include_paths': ['COPYING', 'data/DATA2'], + 'exclude_paths': None, + 'squash_empty_commits': False} + 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 +commit refs/heads/master +mark :4 +committer Joe <joe@example.com> 1234567890 +1000 +data 19 +unknown from commit +from :999 +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 data/DATA2 +""" +) + + def test_with_directory_includes(self): + params = {'include_paths': ['data/'], + 'exclude_paths': None, + 'squash_empty_commits': False} + self.assertFiltering(_SAMPLE_FROM_MERGE_COMMIT, params, \ +"""commit refs/heads/master +mark :3 +committer Joe <joe@example.com> 1234567890 +1000 +data 6 +import +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 +""") |