bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4409.1.21
by Vincent Ladeuil
Fix failing test. |
1 |
# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
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 |
#
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
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 |
#
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
16 |
|
17 |
||
18 |
"""Black-box tests for bzr revno.
|
|
19 |
"""
|
|
20 |
||
21 |
import os |
|
22 |
||
|
4409.1.21
by Vincent Ladeuil
Fix failing test. |
23 |
from bzrlib import tests |
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
24 |
|
|
4409.1.21
by Vincent Ladeuil
Fix failing test. |
25 |
class TestRevno(tests.TestCaseWithTransport): |
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
26 |
|
27 |
def test_revno(self): |
|
28 |
||
29 |
def bzr(*args, **kwargs): |
|
30 |
return self.run_bzr(*args, **kwargs)[0] |
|
31 |
||
32 |
os.mkdir('a') |
|
33 |
os.chdir('a') |
|
34 |
bzr('init') |
|
35 |
self.assertEquals(int(bzr('revno')), 0) |
|
36 |
||
37 |
open('foo', 'wb').write('foo\n') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
38 |
bzr('add foo') |
39 |
bzr('commit -m foo') |
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
40 |
self.assertEquals(int(bzr('revno')), 1) |
41 |
||
42 |
os.mkdir('baz') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
43 |
bzr('add baz') |
44 |
bzr('commit -m baz') |
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
45 |
self.assertEquals(int(bzr('revno')), 2) |
46 |
||
47 |
os.chdir('..') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
48 |
self.assertEquals(int(bzr('revno a')), 2) |
49 |
self.assertEquals(int(bzr('revno a/baz')), 2) |
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
50 |
|
|
4409.1.2
by Matthew Fuller
Add tests for revno --tree. |
51 |
def test_revno_tree(self): |
52 |
# Make branch and checkout
|
|
|
4409.1.8
by John Arbash Meinel
Small tweaks to to the tests for --tree support. |
53 |
wt = self.make_branch_and_tree('branch') |
54 |
checkout = wt.branch.create_checkout('checkout', lightweight=True) |
|
|
4409.1.2
by Matthew Fuller
Add tests for revno --tree. |
55 |
|
56 |
# Get the checkout out of date
|
|
57 |
self.build_tree(['branch/file']) |
|
|
4409.1.8
by John Arbash Meinel
Small tweaks to to the tests for --tree support. |
58 |
wt.add(['file']) |
59 |
wt.commit('mkfile') |
|
|
4409.1.2
by Matthew Fuller
Add tests for revno --tree. |
60 |
|
61 |
# Make sure revno says we're on 1
|
|
62 |
out,err = self.run_bzr('revno checkout') |
|
63 |
self.assertEqual('', err) |
|
64 |
self.assertEqual('1\n', out) |
|
65 |
||
66 |
# Make sure --tree knows it's still on 0
|
|
67 |
out,err = self.run_bzr('revno --tree checkout') |
|
68 |
self.assertEqual('', err) |
|
69 |
self.assertEqual('0\n', out) |
|
|
1185.50.17
by John Arbash Meinel
Forgot to add the test case |
70 |
|
|
4409.1.16
by Matthew Fuller
Add a test for revno --tree on something without a tree. |
71 |
def test_revno_tree_no_tree(self): |
72 |
# Make treeless branch
|
|
73 |
b = self.make_branch('branch') |
|
74 |
||
75 |
# Try getting it's --tree revno
|
|
76 |
out,err = self.run_bzr('revno --tree branch', retcode=3) |
|
77 |
self.assertEqual('', out) |
|
78 |
self.assertEqual('bzr: ERROR: No WorkingTree exists for "branch".\n', |
|
79 |
err) |
|
80 |
||
|
4409.1.9
by John Arbash Meinel
Add tests that dotted revno and unknown revno are both supported. |
81 |
def test_dotted_revno_tree(self): |
82 |
builder = self.make_branch_builder('branch') |
|
83 |
builder.start_series() |
|
84 |
builder.build_snapshot('A-id', None, [ |
|
85 |
('add', ('', 'root-id', 'directory', None)), |
|
86 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
|
87 |
builder.build_snapshot('B-id', ['A-id'], []) |
|
88 |
builder.build_snapshot('C-id', ['A-id', 'B-id'], []) |
|
89 |
builder.finish_series() |
|
90 |
b = builder.get_branch() |
|
91 |
co_b = b.create_checkout('checkout_b', lightweight=True, |
|
92 |
revision_id='B-id') |
|
93 |
out, err = self.run_bzr('revno checkout_b') |
|
94 |
self.assertEqual('', err) |
|
95 |
self.assertEqual('2\n', out) |
|
96 |
out, err = self.run_bzr('revno --tree checkout_b') |
|
97 |
self.assertEqual('', err) |
|
98 |
self.assertEqual('1.1.1\n', out) |
|
99 |
||
100 |
def test_stale_revno_tree(self): |
|
101 |
builder = self.make_branch_builder('branch') |
|
102 |
builder.start_series() |
|
103 |
builder.build_snapshot('A-id', None, [ |
|
104 |
('add', ('', 'root-id', 'directory', None)), |
|
105 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
|
106 |
builder.build_snapshot('B-id', ['A-id'], []) |
|
107 |
builder.build_snapshot('C-id', ['A-id'], []) |
|
108 |
builder.finish_series() |
|
109 |
b = builder.get_branch() |
|
110 |
# The branch is now at "C-id", but the checkout is still at "B-id"
|
|
111 |
# which is no longer in the history
|
|
112 |
co_b = b.create_checkout('checkout_b', lightweight=True, |
|
113 |
revision_id='B-id') |
|
114 |
out, err = self.run_bzr('revno checkout_b') |
|
115 |
self.assertEqual('', err) |
|
116 |
self.assertEqual('2\n', out) |
|
117 |
out, err = self.run_bzr('revno --tree checkout_b') |
|
118 |
self.assertEqual('', err) |
|
119 |
self.assertEqual('???\n', out) |
|
|
6202.1.1
by Jelmer Vernooij
'bzr revno' now takes a --revision argument. |
120 |
|
121 |
def test_revno_with_revision(self): |
|
122 |
wt = self.make_branch_and_tree('.') |
|
123 |
revid1 = wt.commit('rev1') |
|
124 |
revid2 = wt.commit('rev2') |
|
125 |
||
126 |
out, err = self.run_bzr('revno -r-2 .') |
|
127 |
self.assertEqual('1\n', out) |
|
128 |
||
129 |
out, err = self.run_bzr('revno -rrevid:%s .' % revid1) |
|
130 |
self.assertEqual('1\n', out) |
|
|
6202.1.2
by Jelmer Vernooij
Add check for using --tree and --revision together. |
131 |
|
132 |
def test_revno_and_tree_mutually_exclusive(self): |
|
133 |
wt = self.make_branch_and_tree('.') |
|
134 |
out, err = self.run_bzr('revno -r-2 --tree .', retcode=3) |
|
135 |
self.assertEqual('', out) |
|
136 |
self.assertEqual( |
|
137 |
'bzr: ERROR: --tree and --revision can not be used together\n', |
|
138 |
err) |
|
|
6283.1.4
by Jelmer Vernooij
Add revno hpss call count. |
139 |
|
140 |
||
141 |
class TestSmartServerRevno(tests.TestCaseWithTransport): |
|
142 |
||
143 |
def test_simple_branch_revno(self): |
|
144 |
self.setup_smart_server_with_call_log() |
|
145 |
t = self.make_branch_and_tree('branch') |
|
146 |
self.build_tree_contents([('branch/foo', 'thecontents')]) |
|
147 |
t.add("foo") |
|
148 |
revid = t.commit("message") |
|
149 |
self.reset_smart_call_log() |
|
150 |
out, err = self.run_bzr(['revno', self.get_url('branch')]) |
|
151 |
# This figure represent the amount of work to perform this use case. It
|
|
152 |
# is entirely ok to reduce this number if a test fails due to rpc_count
|
|
153 |
# being too low. If rpc_count increases, more network roundtrips have
|
|
154 |
# become necessary for this use case. Please do not adjust this number
|
|
155 |
# upwards without agreement from bzr's network support maintainers.
|
|
|
6263.1.8
by Jelmer Vernooij
Merge bzr.dev, fix hpss call counts. |
156 |
self.assertLength(6, self.hpss_calls) |
|
6283.1.4
by Jelmer Vernooij
Add revno hpss call count. |
157 |
|
158 |
def test_simple_branch_revno_lookup(self): |
|
159 |
self.setup_smart_server_with_call_log() |
|
160 |
t = self.make_branch_and_tree('branch') |
|
161 |
self.build_tree_contents([('branch/foo', 'thecontents')]) |
|
162 |
t.add("foo") |
|
163 |
revid1 = t.commit("message") |
|
164 |
revid2 = t.commit("message") |
|
165 |
self.reset_smart_call_log() |
|
166 |
out, err = self.run_bzr(['revno', '-rrevid:' + revid1, |
|
167 |
self.get_url('branch')]) |
|
168 |
# This figure represent the amount of work to perform this use case. It
|
|
169 |
# is entirely ok to reduce this number if a test fails due to rpc_count
|
|
170 |
# being too low. If rpc_count increases, more network roundtrips have
|
|
171 |
# become necessary for this use case. Please do not adjust this number
|
|
172 |
# upwards without agreement from bzr's network support maintainers.
|
|
|
6263.1.8
by Jelmer Vernooij
Merge bzr.dev, fix hpss call counts. |
173 |
self.assertLength(5, self.hpss_calls) |