summaryrefslogtreecommitdiff
path: root/fastimport/tests/test_filter_processor.py
blob: 4472424c325e277c63bfac22c7569d0bf2f680b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
# Copyright (C) 2009 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""Test FilterProcessor"""

from cStringIO import StringIO

from testtools import TestCase

from fastimport import (
    parser,
    )

from fastimport.processors import (
    filter_processor,
    )


# A sample input stream containing all (top level) import commands
_SAMPLE_ALL = \
"""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
checkpoint
progress first import done
reset refs/remote/origin/master
from :2
tag v0.1
from :2
tagger Joe <joe@example.com> 1234567890 +1000
data 12
release v0.1
"""


# A sample input stream creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
_SAMPLE_WITH_DIR = \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 doc/README.txt
blob
mark :2
data 17
Life
is
good ...
commit refs/heads/master
mark :101
committer a <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :2 NEWS
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :101
M 644 :3 doc/README.txt
M 644 :4 doc/index.txt
"""

class TestCaseWithFiltering(TestCase):

    def assertFiltering(self, input, params, expected):
        outf = StringIO()
        proc = filter_processor.FilterProcessor(
            params=params)
        proc.outf = outf
        s = StringIO(input)
        p = parser.ImportParser(s)
        proc.process(p.iter_commands)
        out = outf.getvalue()
        self.assertEquals(expected, out)

class TestNoFiltering(TestCaseWithFiltering):

    def test_params_not_given(self):
        self.assertFiltering(_SAMPLE_ALL, None, _SAMPLE_ALL)

    def test_params_are_none(self):
        params = {'include_paths': None, 'exclude_paths': None}
        self.assertFiltering(_SAMPLE_ALL, params, _SAMPLE_ALL)


class TestIncludePaths(TestCaseWithFiltering):

    def test_file_in_root(self):
        # Things to note:
        # * only referenced blobs are retained
        # * from clause is dropped from the first command
        params = {'include_paths': ['NEWS']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :2
data 17
Life
is
good ...
commit refs/heads/master
mark :101
committer a <b@c> 1234798653 +0000
data 8
test
ing
M 644 :2 NEWS
""")

    def test_file_in_subdir(self):
        #  Additional things to note:
        # * new root: path is now index.txt, not doc/index.txt
        # * other files changed in matching commits are excluded
        params = {'include_paths': ['doc/index.txt']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
M 644 :4 index.txt
""")

    def test_file_with_changes(self):
        #  Additional things to note:
        # * from updated to reference parents in the output
        params = {'include_paths': ['doc/README.txt']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
""")

    def test_subdir(self):
        params = {'include_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
""")

    def test_multiple_files_in_subdir(self):
        # The new root should be the subdrectory
        params = {'include_paths': ['doc/README.txt', 'doc/index.txt']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
""")


class TestExcludePaths(TestCaseWithFiltering):

    def test_file_in_root(self):
        params = {'exclude_paths': ['NEWS']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 doc/README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 doc/README.txt
M 644 :4 doc/index.txt
""")

    def test_file_in_subdir(self):
        params = {'exclude_paths': ['doc/README.txt']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :2
data 17
Life
is
good ...
commit refs/heads/master
mark :101
committer a <b@c> 1234798653 +0000
data 8
test
ing
M 644 :2 NEWS
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :101
M 644 :4 doc/index.txt
""")

    def test_subdir(self):
        params = {'exclude_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :2
data 17
Life
is
good ...
commit refs/heads/master
mark :101
committer a <b@c> 1234798653 +0000
data 8
test
ing
M 644 :2 NEWS
""")

    def test_multple_files(self):
        params = {'exclude_paths': ['doc/index.txt', 'NEWS']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 doc/README.txt
blob
mark :3
data 19
Welcome!
my friend
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 doc/README.txt
""")


class TestIncludeAndExcludePaths(TestCaseWithFiltering):

    def test_included_dir_and_excluded_file(self):
        params = {'include_paths': ['doc/'], 'exclude_paths': ['doc/index.txt']}
        self.assertFiltering(_SAMPLE_WITH_DIR, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
""")


# A sample input stream creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
#
# It then renames doc/README.txt => doc/README
_SAMPLE_WITH_RENAME_INSIDE = _SAMPLE_WITH_DIR + \
"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
R doc/README.txt doc/README
"""

# A sample input stream creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
#
# It then renames doc/README.txt => README
_SAMPLE_WITH_RENAME_TO_OUTSIDE = _SAMPLE_WITH_DIR + \
"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
R doc/README.txt README
"""

# A sample input stream creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
#
# It then renames NEWS => doc/NEWS
_SAMPLE_WITH_RENAME_TO_INSIDE = _SAMPLE_WITH_DIR + \
"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
R NEWS doc/NEWS
"""

class TestIncludePathsWithRenames(TestCaseWithFiltering):

    def test_rename_all_inside(self):
        # These rename commands ought to be kept but adjusted for the new root
        params = {'include_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_RENAME_INSIDE, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
R README.txt README
""")

    def test_rename_to_outside(self):
        # These rename commands become deletes
        params = {'include_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_RENAME_TO_OUTSIDE, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
D README.txt
""")

    def test_rename_to_inside(self):
        # This ought to create a new file but doesn't yet
        params = {'include_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_RENAME_TO_INSIDE, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
""")


# A sample input stream creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
#
# It then copies doc/README.txt => doc/README
_SAMPLE_WITH_COPY_INSIDE = _SAMPLE_WITH_DIR + \
"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
C doc/README.txt doc/README
"""

# A sample input stream creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
#
# It then copies doc/README.txt => README
_SAMPLE_WITH_COPY_TO_OUTSIDE = _SAMPLE_WITH_DIR + \
"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
C doc/README.txt README
"""

# A sample input stream creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
#
# It then copies NEWS => doc/NEWS
_SAMPLE_WITH_COPY_TO_INSIDE = _SAMPLE_WITH_DIR + \
"""commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
C NEWS doc/NEWS
"""


class TestIncludePathsWithCopies(TestCaseWithFiltering):

    def test_copy_all_inside(self):
        # These copy commands ought to be kept but adjusted for the new root
        params = {'include_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_COPY_INSIDE, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
commit refs/heads/master
mark :103
committer d <b@c> 1234798653 +0000
data 10
move intro
from :102
C README.txt README
""")

    def test_copy_to_outside(self):
        # This can be ignored
        params = {'include_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_COPY_TO_OUTSIDE, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
""")

    def test_copy_to_inside(self):
        # This ought to create a new file but doesn't yet
        params = {'include_paths': ['doc/']}
        self.assertFiltering(_SAMPLE_WITH_COPY_TO_INSIDE, params, \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
M 644 :1 README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
M 644 :3 README.txt
M 644 :4 index.txt
""")


# A sample input stream with deleteall's creating the following tree:
#
#  NEWS
#  doc/README.txt
#  doc/index.txt
_SAMPLE_WITH_DELETEALL = \
"""blob
mark :1
data 9
Welcome!
commit refs/heads/master
mark :100
committer a <b@c> 1234798653 +0000
data 4
test
deleteall
M 644 :1 doc/README.txt
blob
mark :3
data 19
Welcome!
my friend
blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
from :100
deleteall
M 644 :3 doc/README.txt
M 644 :4 doc/index.txt
"""


class TestIncludePathsWithDeleteAll(TestCaseWithFiltering):

    def test_deleteall(self):
        params = {'include_paths': ['doc/index.txt']}
        self.assertFiltering(_SAMPLE_WITH_DELETEALL, params, \
"""blob
mark :4
data 11
== Docs ==
commit refs/heads/master
mark :102
committer d <b@c> 1234798653 +0000
data 8
test
ing
deleteall
M 644 :4 index.txt
""")


_SAMPLE_WITH_TAGS = _SAMPLE_WITH_DIR + \
"""tag v0.1
from :100
tagger d <b@c> 1234798653 +0000
data 12
release v0.1
tag v0.2
from :102
tagger d <b@c> 1234798653 +0000
data 12
release v0.2
"""

class TestIncludePathsWithTags(TestCaseWithFiltering):

    def test_tag_retention(self):
        # If a tag references a commit with a parent we kept,
        # keep the tag but adjust 'from' accordingly.
        # Otherwise, delete the tag command.
        params = {'include_paths': ['NEWS']}
        self.assertFiltering(_SAMPLE_WITH_TAGS, params, \
"""blob
mark :2
data 17
Life
is
good ...
commit refs/heads/master
mark :101
committer a <b@c> 1234798653 +0000
data 8
test
ing
M 644 :2 NEWS
tag v0.2
from :101
tagger d <b@c> 1234798653 +0000
data 12
release v0.2
""")


_SAMPLE_WITH_RESETS = _SAMPLE_WITH_DIR + \
"""reset refs/heads/foo
reset refs/heads/bar
from :102
"""

class TestIncludePathsWithResets(TestCaseWithFiltering):

    def test_reset_retention(self):
        # Resets init'ing a branch (without a from) are passed through.
        # If a reset references a commit with a parent we kept,
        # keep the reset but adjust 'from' accordingly.
        params = {'include_paths': ['NEWS']}
        self.assertFiltering(_SAMPLE_WITH_RESETS, params, \
"""blob
mark :2
data 17
Life
is
good ...
commit refs/heads/master
mark :101
committer a <b@c> 1234798653 +0000
data 8
test
ing
M 644 :2 NEWS
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)