~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-11-17 03:20:35 UTC
  • mfrom: (4792.4.3 456036)
  • Revision ID: pqm@pqm.ubuntu.com-20091117032035-s3sgtlixj1lrminn
(Gordon Tyler) Fix IndexError during 'bzr ignore /' (#456036)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
873
873
        state = dirstate.DirState.initialize('dirstate')
874
874
        try:
875
875
            # check precondition to be sure the state does change appropriately.
876
 
            root_entry = (('', '', 'TREE_ROOT'), [('d', '', 0, False, 'x'*32)])
877
 
            self.assertEqual([root_entry], list(state._iter_entries()))
878
 
            self.assertEqual(root_entry, state._get_entry(0, path_utf8=''))
879
 
            self.assertEqual(root_entry,
880
 
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
881
 
            self.assertEqual((None, None),
882
 
                             state._get_entry(0, fileid_utf8='second-root-id'))
883
 
            state.set_path_id('', 'second-root-id')
884
 
            new_root_entry = (('', '', 'second-root-id'),
885
 
                              [('d', '', 0, False, 'x'*32)])
886
 
            expected_rows = [new_root_entry]
 
876
            self.assertEqual(
 
877
                [(('', '', 'TREE_ROOT'), [('d', '', 0, False,
 
878
                   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')])],
 
879
                list(state._iter_entries()))
 
880
            state.set_path_id('', 'foobarbaz')
 
881
            expected_rows = [
 
882
                (('', '', 'foobarbaz'), [('d', '', 0, False,
 
883
                   'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')])]
887
884
            self.assertEqual(expected_rows, list(state._iter_entries()))
888
 
            self.assertEqual(new_root_entry, state._get_entry(0, path_utf8=''))
889
 
            self.assertEqual(new_root_entry, 
890
 
                             state._get_entry(0, fileid_utf8='second-root-id'))
891
 
            self.assertEqual((None, None),
892
 
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
893
885
            # should work across save too
894
886
            state.save()
895
887
        finally:
913
905
        state._validate()
914
906
        try:
915
907
            state.set_parent_trees([('parent-revid', rt)], ghosts=[])
916
 
            root_entry = (('', '', 'TREE_ROOT'),
917
 
                          [('d', '', 0, False, 'x'*32),
918
 
                           ('d', '', 0, False, 'parent-revid')])
919
 
            self.assertEqual(root_entry, state._get_entry(0, path_utf8=''))
920
 
            self.assertEqual(root_entry,
921
 
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
922
 
            self.assertEqual((None, None),
923
 
                             state._get_entry(0, fileid_utf8='Asecond-root-id'))
924
 
            state.set_path_id('', 'Asecond-root-id')
 
908
            state.set_path_id('', 'foobarbaz')
925
909
            state._validate()
926
910
            # now see that it is what we expected
927
 
            old_root_entry = (('', '', 'TREE_ROOT'),
928
 
                              [('a', '', 0, False, ''),
929
 
                               ('d', '', 0, False, 'parent-revid')])
930
 
            new_root_entry = (('', '', 'Asecond-root-id'),
931
 
                              [('d', '', 0, False, ''),
932
 
                               ('a', '', 0, False, '')])
933
 
            expected_rows = [new_root_entry, old_root_entry]
 
911
            expected_rows = [
 
912
                (('', '', 'TREE_ROOT'),
 
913
                    [('a', '', 0, False, ''),
 
914
                     ('d', '', 0, False, 'parent-revid'),
 
915
                     ]),
 
916
                (('', '', 'foobarbaz'),
 
917
                    [('d', '', 0, False, ''),
 
918
                     ('a', '', 0, False, ''),
 
919
                     ]),
 
920
                ]
934
921
            state._validate()
935
922
            self.assertEqual(expected_rows, list(state._iter_entries()))
936
 
            self.assertEqual(new_root_entry, state._get_entry(0, path_utf8=''))
937
 
            self.assertEqual(old_root_entry, state._get_entry(1, path_utf8=''))
938
 
            self.assertEqual((None, None),
939
 
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
940
 
            self.assertEqual(old_root_entry,
941
 
                             state._get_entry(1, fileid_utf8='TREE_ROOT'))
942
 
            self.assertEqual(new_root_entry,
943
 
                             state._get_entry(0, fileid_utf8='Asecond-root-id'))
944
 
            self.assertEqual((None, None),
945
 
                             state._get_entry(1, fileid_utf8='Asecond-root-id'))
946
923
            # should work across save too
947
924
            state.save()
948
925
        finally: