/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-12 20:51:58 UTC
  • mto: (4634.119.5 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: john@arbash-meinel.com-20100112205158-ka4r62tpmtf3aglg
Fix a bug in the dirstate logic for 'set_path_id'.

It was a bit tricky to sort out, because it depends on the sort order
of sets. Basically 'set_path_id' was accidentally adding the old
file-id a a location to get the entry for the new file-id.
And then the _get_entry lookup would see that the entry was
absent in the given tree (because it doesn't validate that the
file-id for the entry line actually matches the file-id supplied).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
879
879
            self.assertEqual(root_entry,
880
880
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
881
881
            self.assertEqual((None, None),
882
 
                             state._get_entry(0, fileid_utf8='foobarbaz'))
883
 
            state.set_path_id('', 'foobarbaz')
884
 
            new_root_entry = (('', '', 'foobarbaz'),
 
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
885
                              [('d', '', 0, False, 'x'*32)])
886
886
            expected_rows = [new_root_entry]
887
887
            self.assertEqual(expected_rows, list(state._iter_entries()))
888
888
            self.assertEqual(new_root_entry, state._get_entry(0, path_utf8=''))
889
889
            self.assertEqual(new_root_entry, 
890
 
                             state._get_entry(0, fileid_utf8='foobarbaz'))
 
890
                             state._get_entry(0, fileid_utf8='second-root-id'))
891
891
            self.assertEqual((None, None),
892
892
                             state._get_entry(0, fileid_utf8='TREE_ROOT'))
893
893
            # should work across save too
913
913
        state._validate()
914
914
        try:
915
915
            state.set_parent_trees([('parent-revid', rt)], ghosts=[])
916
 
            state.set_path_id('', 'foobarbaz')
 
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')
917
925
            state._validate()
918
926
            # now see that it is what we expected
919
 
            expected_rows = [
920
 
                (('', '', 'TREE_ROOT'),
921
 
                    [('a', '', 0, False, ''),
922
 
                     ('d', '', 0, False, 'parent-revid'),
923
 
                     ]),
924
 
                (('', '', 'foobarbaz'),
925
 
                    [('d', '', 0, False, ''),
926
 
                     ('a', '', 0, False, ''),
927
 
                     ]),
928
 
                ]
 
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]
929
934
            state._validate()
930
935
            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'))
931
946
            # should work across save too
932
947
            state.save()
933
948
        finally: