~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_parent.py

Merge invalid-parent fix from John

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005 by Canonical Ltd
 
1
# Copyright (C) 2004, 2005, 2006 by 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
48
48
        self.assertEqual(None, b.get_parent())
49
49
 
50
50
        b.set_parent('../other_branch')
51
 
        cwd = getcwd()
52
51
 
53
52
        self.assertEqual(local_path_to_url('../other_branch'), b.get_parent())
54
53
        path = local_path_to_url('../yanb')
60
59
 
61
60
        self.assertRaises(bzrlib.errors.InvalidURL, b.set_parent, u'\xb5')
62
61
        b.set_parent(escape(u'\xb5'))
63
 
        self.assertEqual('%C2%B5', 
 
62
        self.assertEqual('%C2%B5',
64
63
            b.control_files.get('parent').read().strip('\n'))
65
64
 
66
65
        self.assertEqual(b.base + '%C2%B5', b.get_parent())
74
73
            b.control_files.put('parent', cStringIO.StringIO('/local/abs/path'))
75
74
            self.assertEqual('file:///local/abs/path', b.get_parent())
76
75
 
 
76
    def test_get_invalid_parent(self):
 
77
        b = self.make_branch('.')
 
78
 
 
79
        cwd = getcwd()
 
80
        n_dirs = len(cwd.split('/'))
 
81
 
 
82
        # Force the relative path to be something invalid
 
83
        # This should attempt to go outside the filesystem
 
84
        path = ('../'*(n_dirs+5)) + 'foo'
 
85
        b.control_files.put('parent', cStringIO.StringIO(path))
 
86
 
 
87
        # With an invalid branch parent, just return None
 
88
        self.assertRaises(bzrlib.errors.InaccessibleParent, b.get_parent)
 
89