~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-07-14 15:18:01 UTC
  • mto: (1904.2.2 bzr.mbp.release)
  • mto: This revision was merged to the branch mainline in revision 1913.
  • Revision ID: john@arbash-meinel.com-20060714151801-38dffed7343ab5e6
Let Branch.get_parent() return None if parent is not accessible, (bug #52976)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.assertEqual(None, b.get_parent())
 
89