bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2524.1.1
by Aaron Bentley
Revert broken changes |
1 |
# Copyright (C) 2007 Canonical Ltd
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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 |
"""Tests for Branch.sprout()"""
|
|
18 |
||
|
3763.9.4
by Daniel Clemente
New test for utf-8 symlinks in BzrDir.sprout |
19 |
import os |
|
2524.1.1
by Aaron Bentley
Revert broken changes |
20 |
from bzrlib import ( |
|
3834.5.1
by Andrew Bennetts
Improve test_sprout. |
21 |
branch as _mod_branch, |
|
2524.1.1
by Aaron Bentley
Revert broken changes |
22 |
remote, |
|
2487.2.4
by Aaron Bentley
Add test to ensure we can branch from repository revisions |
23 |
revision as _mod_revision, |
|
2524.1.1
by Aaron Bentley
Revert broken changes |
24 |
tests, |
25 |
)
|
|
|
3763.9.4
by Daniel Clemente
New test for utf-8 symlinks in BzrDir.sprout |
26 |
from bzrlib.tests import KnownFailure, SymlinkFeature, UnicodeFilenameFeature |
|
2524.1.1
by Aaron Bentley
Revert broken changes |
27 |
from bzrlib.tests.branch_implementations import TestCaseWithBranch |
28 |
||
29 |
||
30 |
class TestSprout(TestCaseWithBranch): |
|
31 |
||
32 |
def test_sprout_branch_nickname(self): |
|
33 |
# test the nick name is reset always
|
|
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
34 |
raise tests.TestSkipped('XXX branch sprouting is not yet tested.') |
|
2524.1.1
by Aaron Bentley
Revert broken changes |
35 |
|
36 |
def test_sprout_branch_parent(self): |
|
37 |
source = self.make_branch('source') |
|
38 |
target = source.bzrdir.sprout(self.get_url('target')).open_branch() |
|
39 |
self.assertEqual(source.bzrdir.root_transport.base, target.get_parent()) |
|
40 |
||
|
3834.5.2
by John Arbash Meinel
Track down the various BranchFormats that weren't setting the branch format as part of the _matchingbzrdir format. |
41 |
def test_sprout_uses_bzrdir_branch_format(self): |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
42 |
# branch.sprout(bzrdir) is defined as using the branch format selected
|
43 |
# by bzrdir; format preservation is achieved by parameterising the
|
|
44 |
# bzrdir during bzrdir.sprout, which is where stacking compatibility
|
|
45 |
# checks are done. So this test tests that each implementation of
|
|
46 |
# Branch.sprout delegates appropriately to the bzrdir which the
|
|
47 |
# branch is being created in, rather than testing that the result is
|
|
48 |
# in the format that we are testing (which is what would happen if
|
|
49 |
# the branch did not delegate appropriately).
|
|
|
3834.5.1
by Andrew Bennetts
Improve test_sprout. |
50 |
if isinstance(self.branch_format, _mod_branch.BranchReferenceFormat): |
51 |
raise tests.TestNotApplicable('cannot sprout to a reference') |
|
52 |
# Start with a format that is unlikely to be the target format
|
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
53 |
# We call the super class to allow overriding the format of creation)
|
|
3834.5.1
by Andrew Bennetts
Improve test_sprout. |
54 |
source = tests.TestCaseWithTransport.make_branch(self, 'old-branch', |
55 |
format='metaweave') |
|
|
3834.5.2
by John Arbash Meinel
Track down the various BranchFormats that weren't setting the branch format as part of the _matchingbzrdir format. |
56 |
target_bzrdir = self.make_bzrdir('target') |
57 |
target_bzrdir.create_repository() |
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
58 |
result_format = self.branch_format |
59 |
if isinstance(target_bzrdir, remote.RemoteBzrDir): |
|
60 |
# for a remote bzrdir, we need to parameterise it with a branch
|
|
61 |
# format, as, after creation, the newly opened remote objects
|
|
62 |
# do not have one unless a branch was created at the time.
|
|
63 |
# We use branch format 6 because its not the default, and its not
|
|
64 |
# metaweave either.
|
|
65 |
target_bzrdir._format.set_branch_format(_mod_branch.BzrBranchFormat6()) |
|
66 |
result_format = target_bzrdir._format.get_branch_format() |
|
|
3834.5.1
by Andrew Bennetts
Improve test_sprout. |
67 |
target = source.sprout(target_bzrdir) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
68 |
if isinstance(target, remote.RemoteBranch): |
69 |
# we have to look at the real branch to see whether RemoteBranch
|
|
70 |
# did the right thing.
|
|
71 |
target._ensure_real() |
|
72 |
target = target._real_branch |
|
73 |
self.assertIs(result_format.__class__, target._format.__class__) |
|
|
2524.1.1
by Aaron Bentley
Revert broken changes |
74 |
|
75 |
def test_sprout_partial(self): |
|
76 |
# test sprouting with a prefix of the revision-history.
|
|
77 |
# also needs not-on-revision-history behaviour defined.
|
|
78 |
wt_a = self.make_branch_and_tree('a') |
|
79 |
self.build_tree(['a/one']) |
|
80 |
wt_a.add(['one']) |
|
81 |
wt_a.commit('commit one', rev_id='1') |
|
82 |
self.build_tree(['a/two']) |
|
83 |
wt_a.add(['two']) |
|
84 |
wt_a.commit('commit two', rev_id='2') |
|
85 |
repo_b = self.make_repository('b') |
|
86 |
repo_a = wt_a.branch.repository |
|
87 |
repo_a.copy_content_into(repo_b) |
|
88 |
br_b = wt_a.branch.sprout(repo_b.bzrdir, revision_id='1') |
|
89 |
self.assertEqual('1', br_b.last_revision()) |
|
90 |
||
91 |
def test_sprout_partial_not_in_revision_history(self): |
|
92 |
"""We should be able to sprout from any revision in ancestry.""" |
|
93 |
wt = self.make_branch_and_tree('source') |
|
94 |
self.build_tree(['source/a']) |
|
95 |
wt.add('a') |
|
96 |
wt.commit('rev1', rev_id='rev1') |
|
97 |
wt.commit('rev2-alt', rev_id='rev2-alt') |
|
98 |
wt.set_parent_ids(['rev1']) |
|
99 |
wt.branch.set_last_revision_info(1, 'rev1') |
|
100 |
wt.commit('rev2', rev_id='rev2') |
|
101 |
wt.set_parent_ids(['rev2', 'rev2-alt']) |
|
102 |
wt.commit('rev3', rev_id='rev3') |
|
103 |
||
104 |
repo = self.make_repository('target') |
|
105 |
repo.fetch(wt.branch.repository) |
|
106 |
branch2 = wt.branch.sprout(repo.bzrdir, revision_id='rev2-alt') |
|
107 |
self.assertEqual((2, 'rev2-alt'), branch2.last_revision_info()) |
|
108 |
self.assertEqual(['rev1', 'rev2-alt'], branch2.revision_history()) |
|
|
2487.2.4
by Aaron Bentley
Add test to ensure we can branch from repository revisions |
109 |
|
110 |
def test_sprout_from_any_repo_revision(self): |
|
111 |
"""We should be able to sprout from any revision.""" |
|
112 |
wt = self.make_branch_and_tree('source') |
|
113 |
self.build_tree(['source/a']) |
|
114 |
wt.add('a') |
|
115 |
wt.commit('rev1a', rev_id='rev1a') |
|
116 |
# simulated uncommit
|
|
117 |
wt.branch.set_last_revision_info(0, _mod_revision.NULL_REVISION) |
|
|
2598.5.3
by Aaron Bentley
Push NULL_REVISION deeper |
118 |
wt.set_last_revision(_mod_revision.NULL_REVISION) |
|
2796.1.4
by Aaron Bentley
Fix up various test cases |
119 |
wt.revert() |
|
2487.2.4
by Aaron Bentley
Add test to ensure we can branch from repository revisions |
120 |
wt.commit('rev1b', rev_id='rev1b') |
121 |
wt2 = wt.bzrdir.sprout('target', |
|
122 |
revision_id='rev1a').open_workingtree() |
|
123 |
self.assertEqual('rev1a', wt2.last_revision()) |
|
124 |
self.failUnlessExists('target/a') |
|
|
3763.9.4
by Daniel Clemente
New test for utf-8 symlinks in BzrDir.sprout |
125 |
|
|
3763.9.7
by Daniel Clemente
Tested Unicode target rather than always trying to create it in UTF-8. Test renamed |
126 |
def test_sprout_with_unicode_symlink(self): |
|
3763.9.8
by Daniel Clemente
Broken lines, and prepended # before bug numbers |
127 |
# this tests bug #272444
|
|
3763.9.11
by Daniel Clemente
More detailed comment and in broken line |
128 |
# Since the trigger function seems to be set_parent_trees, there exists
|
129 |
# also a similar test, with name test_unicode_symlink, in class
|
|
130 |
# TestSetParents at file workingtree_implementations/test_parents.py
|
|
|
3763.9.4
by Daniel Clemente
New test for utf-8 symlinks in BzrDir.sprout |
131 |
self.requireFeature(SymlinkFeature) |
132 |
self.requireFeature(UnicodeFilenameFeature) |
|
133 |
||
134 |
tree = self.make_branch_and_tree('tree1') |
|
135 |
||
|
3763.9.9
by Daniel Clemente
Used a greek omega instead of an accented 'o' to avoid combining characters |
136 |
# The link points to a file whose name is an omega
|
137 |
# U+03A9 GREEK CAPITAL LETTER OMEGA
|
|
138 |
# UTF-8: ce a9 UTF-16BE: 03a9 Decimal: Ω
|
|
139 |
os.symlink(u'\u03a9','tree1/link_name') |
|
|
3763.9.4
by Daniel Clemente
New test for utf-8 symlinks in BzrDir.sprout |
140 |
tree.add(['link_name'],['link-id']) |
141 |
||
142 |
try: |
|
|
3763.9.12
by Daniel Clemente
Made the tests pass on Python 2.4 and 2.7a0 |
143 |
# python 2.7a0 failed on commit:
|
144 |
revision = tree.commit('added a link to a Unicode target') |
|
145 |
# python 2.5 failed on sprout:
|
|
|
3763.9.4
by Daniel Clemente
New test for utf-8 symlinks in BzrDir.sprout |
146 |
tree.bzrdir.sprout('target') |
147 |
except UnicodeEncodeError, e: |
|
|
3763.9.8
by Daniel Clemente
Broken lines, and prepended # before bug numbers |
148 |
raise KnownFailure('there is no support for' |
149 |
' symlinks to non-ASCII targets (bug #272444)') |
|
|
3763.9.4
by Daniel Clemente
New test for utf-8 symlinks in BzrDir.sprout |
150 |