bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2004, 2005, 2006 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1149
by Martin Pool
- make get_parent() be a method of Branch; add simple tests for it |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1149
by Martin Pool
- make get_parent() be a method of Branch; add simple tests for it |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1149
by Martin Pool
- make get_parent() be a method of Branch; add simple tests for it |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
|
1711.2.46
by John Arbash Meinel
Allow backwards compatibility with absolute local paths in parent |
18 |
import sys |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
19 |
|
|
1685.1.70
by Wouter van Heyst
working on get_parent, set_parent and relative urls, broken |
20 |
import bzrlib.errors |
|
2018.5.167
by Andrew Bennetts
Various changes in response to John's review. |
21 |
from bzrlib.osutils import getcwd |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
22 |
from bzrlib.tests import TestCaseWithTransport |
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
23 |
from bzrlib import urlutils |
|
1149
by Martin Pool
- make get_parent() be a method of Branch; add simple tests for it |
24 |
|
25 |
||
|
1211
by Martin Pool
doc |
26 |
"""Tests for Branch parent URL"""
|
27 |
||
|
1149
by Martin Pool
- make get_parent() be a method of Branch; add simple tests for it |
28 |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
29 |
class TestParent(TestCaseWithTransport): |
|
1185.65.17
by Robert Collins
Merge from integration, mode-changes are broken. |
30 |
|
|
1149
by Martin Pool
- make get_parent() be a method of Branch; add simple tests for it |
31 |
def test_no_default_parent(self): |
32 |
"""Branches should have no parent by default""" |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
33 |
b = self.make_branch('.') |
|
1711.2.46
by John Arbash Meinel
Allow backwards compatibility with absolute local paths in parent |
34 |
self.assertEqual(None, b.get_parent()) |
|
1149
by Martin Pool
- make get_parent() be a method of Branch; add simple tests for it |
35 |
|
36 |
def test_set_get_parent(self): |
|
|
1614.2.14
by Olaf Conradi
Add test case for resetting parent in branch_implementations. |
37 |
"""Set, re-get and reset the parent""" |
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
38 |
b = self.make_branch('subdir') |
|
1185.50.94
by John Arbash Meinel
Updated web page url to http://bazaar-vcs.org |
39 |
url = 'http://bazaar-vcs.org/bzr/bzr.dev' |
|
1150
by Martin Pool
- add new Branch.set_parent and tests |
40 |
b.set_parent(url) |
|
1711.2.46
by John Arbash Meinel
Allow backwards compatibility with absolute local paths in parent |
41 |
self.assertEqual(url, b.get_parent()) |
|
2230.3.8
by Aaron Bentley
Abstract mechanism from policy getting/setting parents |
42 |
self.assertEqual(url, b._get_parent_location()) |
|
1685.1.70
by Wouter van Heyst
working on get_parent, set_parent and relative urls, broken |
43 |
|
|
1614.2.14
by Olaf Conradi
Add test case for resetting parent in branch_implementations. |
44 |
b.set_parent(None) |
|
1711.2.46
by John Arbash Meinel
Allow backwards compatibility with absolute local paths in parent |
45 |
self.assertEqual(None, b.get_parent()) |
|
1685.1.70
by Wouter van Heyst
working on get_parent, set_parent and relative urls, broken |
46 |
|
47 |
b.set_parent('../other_branch') |
|
48 |
||
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
49 |
expected_parent = urlutils.join(self.get_url('subdir'), |
50 |
'../other_branch') |
|
51 |
self.assertEqual(expected_parent, b.get_parent()) |
|
52 |
path = urlutils.join(self.get_url('subdir'), '../yanb') |
|
|
1685.1.70
by Wouter van Heyst
working on get_parent, set_parent and relative urls, broken |
53 |
b.set_parent(path) |
|
2230.3.8
by Aaron Bentley
Abstract mechanism from policy getting/setting parents |
54 |
self.assertEqual('../yanb', b._get_parent_location()) |
|
1711.2.46
by John Arbash Meinel
Allow backwards compatibility with absolute local paths in parent |
55 |
self.assertEqual(path, b.get_parent()) |
|
1685.1.70
by Wouter van Heyst
working on get_parent, set_parent and relative urls, broken |
56 |
|
57 |
||
58 |
self.assertRaises(bzrlib.errors.InvalidURL, b.set_parent, u'\xb5') |
|
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
59 |
b.set_parent(urlutils.escape(u'\xb5')) |
|
2230.3.8
by Aaron Bentley
Abstract mechanism from policy getting/setting parents |
60 |
self.assertEqual('%C2%B5', b._get_parent_location()) |
|
1711.2.46
by John Arbash Meinel
Allow backwards compatibility with absolute local paths in parent |
61 |
|
62 |
self.assertEqual(b.base + '%C2%B5', b.get_parent()) |
|
63 |
||
64 |
# Handle the case for older style absolute local paths
|
|
65 |
if sys.platform == 'win32': |
|
66 |
# TODO: jam 20060515 Do we want to special case Windows local
|
|
67 |
# paths as well? Nobody has complained about it.
|
|
68 |
pass
|
|
69 |
else: |
|
|
2230.3.8
by Aaron Bentley
Abstract mechanism from policy getting/setting parents |
70 |
b._set_parent_location('/local/abs/path') |
|
1711.2.46
by John Arbash Meinel
Allow backwards compatibility with absolute local paths in parent |
71 |
self.assertEqual('file:///local/abs/path', b.get_parent()) |
|
1685.1.70
by Wouter van Heyst
working on get_parent, set_parent and relative urls, broken |
72 |
|
|
1864.7.1
by John Arbash Meinel
Let Branch.get_parent() return None if parent is not accessible, (bug #52976) |
73 |
def test_get_invalid_parent(self): |
74 |
b = self.make_branch('.') |
|
75 |
||
76 |
cwd = getcwd() |
|
77 |
n_dirs = len(cwd.split('/')) |
|
78 |
||
79 |
# Force the relative path to be something invalid
|
|
80 |
# This should attempt to go outside the filesystem
|
|
81 |
path = ('../'*(n_dirs+5)) + 'foo' |
|
|
2230.3.8
by Aaron Bentley
Abstract mechanism from policy getting/setting parents |
82 |
b._set_parent_location(path) |
|
1864.7.1
by John Arbash Meinel
Let Branch.get_parent() return None if parent is not accessible, (bug #52976) |
83 |
|
84 |
# With an invalid branch parent, just return None
|
|
|
1864.7.2
by John Arbash Meinel
Test that we copy the parent across properly (if it is available) |
85 |
self.assertRaises(bzrlib.errors.InaccessibleParent, b.get_parent) |
|
1864.7.1
by John Arbash Meinel
Let Branch.get_parent() return None if parent is not accessible, (bug #52976) |
86 |