bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2012, 2016 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
897
by Martin Pool
- merge john's revision-naming code |
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 |
#
|
|
897
by Martin Pool
- merge john's revision-naming code |
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 |
#
|
|
897
by Martin Pool
- merge john's revision-naming code |
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
|
|
897
by Martin Pool
- merge john's revision-naming code |
16 |
|
|
1948.4.12
by John Arbash Meinel
Some tests for the date: spec |
17 |
import datetime |
|
1185.1.39
by Robert Collins
Robey Pointers before: namespace to clear up usage of dates in revision parameters |
18 |
import time |
|
1432
by Robert Collins
branch: namespace |
19 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
20 |
from breezy import ( |
|
1948.4.1
by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers |
21 |
errors, |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
22 |
revision as _mod_revision, |
|
1948.4.1
by John Arbash Meinel
Update number parsers to raise InvalidRevisionSpec. Update revno: itself so it supports negative numbers |
23 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
24 |
from breezy.tests import TestCaseWithTransport |
25 |
from breezy.revisionspec import ( |
|
|
5671.5.1
by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs. |
26 |
RevisionInfo, |
|
2220.2.3
by Martin Pool
Add tag: revision namespace. |
27 |
RevisionSpec, |
|
5671.5.1
by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs. |
28 |
RevisionSpec_dwim, |
|
2220.2.3
by Martin Pool
Add tag: revision namespace. |
29 |
RevisionSpec_tag, |
30 |
)
|
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
31 |
|
32 |
||
33 |
def spec_in_history(spec, branch): |
|
34 |
"""A simple helper to change a revision spec into a branch search""" |
|
35 |
return RevisionSpec.from_string(spec).in_history(branch) |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
36 |
|
37 |
||
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
38 |
# Basic class, which just creates a really basic set of revisions
|
39 |
class TestRevisionSpec(TestCaseWithTransport): |
|
40 |
||
41 |
def setUp(self): |
|
42 |
super(TestRevisionSpec, self).setUp() |
|
|
1988.4.5
by Robert Collins
revisions can now be specified using dotted-decimal revision numbers. |
43 |
# this sets up a revision graph:
|
44 |
# r1: [] 1
|
|
45 |
# alt_r2: [r1] 1.1.1
|
|
46 |
# r2: [r1, alt_r2] 2
|
|
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
47 |
|
48 |
self.tree = self.make_branch_and_tree('tree') |
|
49 |
self.build_tree(['tree/a']) |
|
|
3298.2.3
by John Arbash Meinel
Add tests that all RevisionSpecs implement in_branch(b, needs_revno) |
50 |
self.tree.lock_write() |
|
3298.2.11
by Aaron Bentley
Update tests for null:, clea up slightly |
51 |
self.addCleanup(self.tree.unlock) |
52 |
self.tree.add(['a']) |
|
53 |
self.tree.commit('a', rev_id='r1') |
|
54 |
||
55 |
self.tree2 = self.tree.bzrdir.sprout('tree2').open_workingtree() |
|
56 |
self.tree2.commit('alt', rev_id='alt_r2') |
|
57 |
||
58 |
self.tree.merge_from_branch(self.tree2.branch) |
|
59 |
self.tree.commit('second', rev_id='r2') |
|
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
60 |
|
61 |
def get_in_history(self, revision_spec): |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
62 |
return spec_in_history(revision_spec, self.tree.branch) |
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
63 |
|
64 |
def assertInHistoryIs(self, exp_revno, exp_revision_id, revision_spec): |
|
65 |
rev_info = self.get_in_history(revision_spec) |
|
66 |
self.assertEqual(exp_revno, rev_info.revno, |
|
|
2325.2.1
by Marien Zwart
Make the test suite failure reporting a bit more robust. |
67 |
'Revision spec: %r returned wrong revno: %r != %r' |
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
68 |
% (revision_spec, exp_revno, rev_info.revno)) |
69 |
self.assertEqual(exp_revision_id, rev_info.rev_id, |
|
|
2325.2.1
by Marien Zwart
Make the test suite failure reporting a bit more robust. |
70 |
'Revision spec: %r returned wrong revision id:' |
71 |
' %r != %r' |
|
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
72 |
% (revision_spec, exp_revision_id, rev_info.rev_id)) |
73 |
||
|
3495.1.1
by John Arbash Meinel
Fix bug #239933, use the right exception for -c0 |
74 |
def assertInvalid(self, revision_spec, extra='', |
75 |
invalid_as_revision_id=True): |
|
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
76 |
try: |
77 |
self.get_in_history(revision_spec) |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
78 |
except errors.InvalidRevisionSpec as e: |
|
1948.4.23
by John Arbash Meinel
Change the handling of negative numbers, to be trapped at revno 1 |
79 |
self.assertEqual(revision_spec, e.spec) |
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
80 |
self.assertEqual(extra, e.extra) |
|
1948.4.5
by John Arbash Meinel
Fix tests for negative entries, and add tests for revno: |
81 |
else: |
|
3495.1.1
by John Arbash Meinel
Fix bug #239933, use the right exception for -c0 |
82 |
self.fail('Expected InvalidRevisionSpec to be raised for' |
83 |
' %r.in_history' % (revision_spec,)) |
|
84 |
if invalid_as_revision_id: |
|
85 |
try: |
|
86 |
spec = RevisionSpec.from_string(revision_spec) |
|
87 |
spec.as_revision_id(self.tree.branch) |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
88 |
except errors.InvalidRevisionSpec as e: |
|
3495.1.1
by John Arbash Meinel
Fix bug #239933, use the right exception for -c0 |
89 |
self.assertEqual(revision_spec, e.spec) |
90 |
self.assertEqual(extra, e.extra) |
|
91 |
else: |
|
92 |
self.fail('Expected InvalidRevisionSpec to be raised for' |
|
|
3495.1.2
by John Arbash Meinel
tweak |
93 |
' %r.as_revision_id' % (revision_spec,)) |
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
94 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
95 |
def assertAsRevisionId(self, revision_id, revision_spec): |
96 |
"""Calling as_revision_id() should return the specified id.""" |
|
97 |
spec = RevisionSpec.from_string(revision_spec) |
|
98 |
self.assertEqual(revision_id, |
|
99 |
spec.as_revision_id(self.tree.branch)) |
|
100 |
||
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
101 |
def get_as_tree(self, revision_spec, tree=None): |
102 |
if tree is None: |
|
103 |
tree = self.tree |
|
104 |
spec = RevisionSpec.from_string(revision_spec) |
|
105 |
return spec.as_tree(tree.branch) |
|
106 |
||
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
107 |
|
|
3460.1.2
by John Arbash Meinel
Add a test for wants_revision_history |
108 |
class RevisionSpecMatchOnTrap(RevisionSpec): |
109 |
||
110 |
def _match_on(self, branch, revs): |
|
111 |
self.last_call = (branch, revs) |
|
112 |
return super(RevisionSpecMatchOnTrap, self)._match_on(branch, revs) |
|
113 |
||
114 |
||
115 |
class TestRevisionSpecBase(TestRevisionSpec): |
|
116 |
||
117 |
def test_wants_no_revision_history(self): |
|
118 |
# If wants_revision_history = False, then _match_on should get None for
|
|
119 |
# the branch revision history
|
|
120 |
spec = RevisionSpecMatchOnTrap('foo', _internal=True) |
|
121 |
spec.in_history(self.tree.branch) |
|
122 |
||
123 |
self.assertEqual((self.tree.branch, None), spec.last_call) |
|
124 |
||
125 |
||
126 |
||
|
1948.4.19
by John Arbash Meinel
All old tests are covered elsewhere |
127 |
class TestOddRevisionSpec(TestRevisionSpec): |
128 |
"""Test things that aren't normally thought of as revision specs""" |
|
129 |
||
130 |
def test_none(self): |
|
|
3298.2.11
by Aaron Bentley
Update tests for null:, clea up slightly |
131 |
self.assertInHistoryIs(None, None, None) |
|
1948.4.19
by John Arbash Meinel
All old tests are covered elsewhere |
132 |
|
133 |
def test_object(self): |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
134 |
self.assertRaises(TypeError, RevisionSpec.from_string, object()) |
|
1948.4.19
by John Arbash Meinel
All old tests are covered elsewhere |
135 |
|
|
1948.4.32
by John Arbash Meinel
Clean up __repr__, as well as add tests that we can handle -r12:branch/ |
136 |
|
|
5671.5.1
by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs. |
137 |
class RevisionSpec_bork(RevisionSpec): |
138 |
||
139 |
prefix = 'irrelevant:' |
|
140 |
||
141 |
def _match_on(self, branch, revs): |
|
142 |
if self.spec == "bork": |
|
|
6336.1.1
by Jelmer Vernooij
Deprecate ``RevisionSpec.wants_revision_history`` and remove any uses of it. |
143 |
return RevisionInfo.from_revision_id(branch, "r1") |
|
5671.5.1
by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs. |
144 |
else: |
145 |
raise errors.InvalidRevisionSpec(self.spec, branch) |
|
146 |
||
147 |
||
|
4569.2.2
by Matthew Fuller
Add tests for DWIM revspecs. |
148 |
class TestRevisionSpec_dwim(TestRevisionSpec): |
149 |
||
150 |
# Don't need to test revno's explicitly since TRS_revno already
|
|
151 |
# covers that well for us
|
|
|
4569.2.11
by Matthew Fuller
Eliminate the TestRevnoFromString() test class by moving all its tests |
152 |
def test_dwim_spec_revno(self): |
153 |
self.assertInHistoryIs(2, 'r2', '2') |
|
154 |
self.assertAsRevisionId('alt_r2', '1.1.1') |
|
|
4569.2.2
by Matthew Fuller
Add tests for DWIM revspecs. |
155 |
|
156 |
def test_dwim_spec_revid(self): |
|
157 |
self.assertInHistoryIs(2, 'r2', 'r2') |
|
158 |
||
159 |
def test_dwim_spec_tag(self): |
|
160 |
self.tree.branch.tags.set_tag('footag', 'r1') |
|
161 |
self.assertAsRevisionId('r1', 'footag') |
|
162 |
self.tree.branch.tags.delete_tag('footag') |
|
163 |
self.assertRaises(errors.InvalidRevisionSpec, |
|
164 |
self.get_in_history, 'footag') |
|
165 |
||
|
4569.2.16
by Matthew Fuller
Add a test that we slip past the revno-checking stage when we're |
166 |
def test_dwim_spec_tag_that_looks_like_revno(self): |
167 |
# Test that we slip past revno with things that look like revnos,
|
|
168 |
# but aren't. Tags are convenient for testing this since we can
|
|
169 |
# make them look however we want.
|
|
170 |
self.tree.branch.tags.set_tag('3', 'r2') |
|
171 |
self.assertAsRevisionId('r2', '3') |
|
172 |
self.build_tree(['tree/b']) |
|
173 |
self.tree.add(['b']) |
|
174 |
self.tree.commit('b', rev_id='r3') |
|
175 |
self.assertAsRevisionId('r3', '3') |
|
176 |
||
|
4569.2.4
by Matthew Fuller
Add date: to the list of things DWIM auto-tries. |
177 |
def test_dwim_spec_date(self): |
178 |
self.assertAsRevisionId('r1', 'today') |
|
179 |
||
|
4569.2.2
by Matthew Fuller
Add tests for DWIM revspecs. |
180 |
def test_dwim_spec_branch(self): |
181 |
self.assertInHistoryIs(None, 'alt_r2', 'tree2') |
|
182 |
||
183 |
def test_dwim_spec_nonexistent(self): |
|
|
4569.2.8
by Matthew Fuller
Use a more precise nonexistent thing in test_dwim_spec_nonexistent(). |
184 |
self.assertInvalid('somethingrandom', invalid_as_revision_id=False) |
|
4569.2.11
by Matthew Fuller
Eliminate the TestRevnoFromString() test class by moving all its tests |
185 |
self.assertInvalid('-1.1', invalid_as_revision_id=False) |
186 |
self.assertInvalid('.1', invalid_as_revision_id=False) |
|
187 |
self.assertInvalid('1..1', invalid_as_revision_id=False) |
|
188 |
self.assertInvalid('1.2..1', invalid_as_revision_id=False) |
|
189 |
self.assertInvalid('1.', invalid_as_revision_id=False) |
|
|
1988.4.5
by Robert Collins
revisions can now be specified using dotted-decimal revision numbers. |
190 |
|
|
5671.5.1
by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs. |
191 |
def test_append_dwim_revspec(self): |
192 |
original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs) |
|
193 |
def reset_dwim_revspecs(): |
|
194 |
RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs |
|
195 |
self.addCleanup(reset_dwim_revspecs) |
|
196 |
RevisionSpec_dwim.append_possible_revspec(RevisionSpec_bork) |
|
197 |
self.assertAsRevisionId('r1', 'bork') |
|
198 |
||
199 |
def test_append_lazy_dwim_revspec(self): |
|
200 |
original_dwim_revspecs = list(RevisionSpec_dwim._possible_revspecs) |
|
201 |
def reset_dwim_revspecs(): |
|
202 |
RevisionSpec_dwim._possible_revspecs = original_dwim_revspecs |
|
203 |
self.addCleanup(reset_dwim_revspecs) |
|
|
5671.5.3
by Jelmer Vernooij
Fix test.. not sure how I missed this. |
204 |
RevisionSpec_dwim.append_possible_lazy_revspec( |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
205 |
"breezy.tests.test_revisionspec", "RevisionSpec_bork") |
|
5671.5.1
by Jelmer Vernooij
Allow lazily registering possible DWIM revspecs. |
206 |
self.assertAsRevisionId('r1', 'bork') |
207 |
||
|
1988.4.5
by Robert Collins
revisions can now be specified using dotted-decimal revision numbers. |
208 |
|
|
1948.4.32
by John Arbash Meinel
Clean up __repr__, as well as add tests that we can handle -r12:branch/ |
209 |
class TestRevisionSpec_revno(TestRevisionSpec): |
210 |
||
211 |
def test_positive_int(self): |
|
|
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
212 |
self.assertInHistoryIs(0, 'null:', '0') |
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
213 |
self.assertInHistoryIs(1, 'r1', '1') |
214 |
self.assertInHistoryIs(2, 'r2', '2') |
|
|
1948.4.23
by John Arbash Meinel
Change the handling of negative numbers, to be trapped at revno 1 |
215 |
self.assertInvalid('3') |
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
216 |
|
|
1988.4.5
by Robert Collins
revisions can now be specified using dotted-decimal revision numbers. |
217 |
def test_dotted_decimal(self): |
218 |
self.assertInHistoryIs(None, 'alt_r2', '1.1.1') |
|
|
3878.3.1
by Marius Kruger
Test invalid dotted revion number directly in TestRevisionSpec_revno |
219 |
self.assertInvalid('1.1.123') |
|
1988.4.5
by Robert Collins
revisions can now be specified using dotted-decimal revision numbers. |
220 |
|
|
1948.4.32
by John Arbash Meinel
Clean up __repr__, as well as add tests that we can handle -r12:branch/ |
221 |
def test_negative_int(self): |
|
1948.4.3
by John Arbash Meinel
Create direct tests for RevisionSpec_int |
222 |
self.assertInHistoryIs(2, 'r2', '-1') |
223 |
self.assertInHistoryIs(1, 'r1', '-2') |
|
224 |
||
|
1948.4.23
by John Arbash Meinel
Change the handling of negative numbers, to be trapped at revno 1 |
225 |
self.assertInHistoryIs(1, 'r1', '-3') |
226 |
self.assertInHistoryIs(1, 'r1', '-4') |
|
227 |
self.assertInHistoryIs(1, 'r1', '-100') |
|
|
1948.4.5
by John Arbash Meinel
Fix tests for negative entries, and add tests for revno: |
228 |
|
229 |
def test_positive(self): |
|
|
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
230 |
self.assertInHistoryIs(0, 'null:', 'revno:0') |
|
1948.4.5
by John Arbash Meinel
Fix tests for negative entries, and add tests for revno: |
231 |
self.assertInHistoryIs(1, 'r1', 'revno:1') |
232 |
self.assertInHistoryIs(2, 'r2', 'revno:2') |
|
233 |
||
234 |
self.assertInvalid('revno:3') |
|
235 |
||
236 |
def test_negative(self): |
|
237 |
self.assertInHistoryIs(2, 'r2', 'revno:-1') |
|
238 |
self.assertInHistoryIs(1, 'r1', 'revno:-2') |
|
239 |
||
|
1948.4.23
by John Arbash Meinel
Change the handling of negative numbers, to be trapped at revno 1 |
240 |
self.assertInHistoryIs(1, 'r1', 'revno:-3') |
241 |
self.assertInHistoryIs(1, 'r1', 'revno:-4') |
|
|
1948.4.6
by John Arbash Meinel
A small bugfix, and more tests for revno: |
242 |
|
243 |
def test_invalid_number(self): |
|
244 |
# Get the right exception text
|
|
245 |
try: |
|
246 |
int('X') |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
247 |
except ValueError as e: |
|
1948.4.6
by John Arbash Meinel
A small bugfix, and more tests for revno: |
248 |
pass
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
249 |
self.assertInvalid('revno:X', extra='\n' + str(e)) |
|
1948.4.6
by John Arbash Meinel
A small bugfix, and more tests for revno: |
250 |
|
251 |
def test_missing_number_and_branch(self): |
|
252 |
self.assertInvalid('revno::', |
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
253 |
extra='\ncannot have an empty revno and no branch') |
|
1948.4.7
by John Arbash Meinel
More revno: tests, now testing the branch/url parameter |
254 |
|
255 |
def test_invalid_number_with_branch(self): |
|
256 |
try: |
|
257 |
int('X') |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
258 |
except ValueError as e: |
|
1948.4.7
by John Arbash Meinel
More revno: tests, now testing the branch/url parameter |
259 |
pass
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
260 |
self.assertInvalid('revno:X:tree2', extra='\n' + str(e)) |
|
1948.4.7
by John Arbash Meinel
More revno: tests, now testing the branch/url parameter |
261 |
|
|
1948.4.16
by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes |
262 |
def test_non_exact_branch(self): |
263 |
# It seems better to require an exact path to the branch
|
|
264 |
# Branch.open() rather than using Branch.open_containing()
|
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
265 |
spec = RevisionSpec.from_string('revno:2:tree2/a') |
|
1948.4.16
by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes |
266 |
self.assertRaises(errors.NotBranchError, |
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
267 |
spec.in_history, self.tree.branch) |
|
1948.4.16
by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes |
268 |
|
|
1948.4.7
by John Arbash Meinel
More revno: tests, now testing the branch/url parameter |
269 |
def test_with_branch(self): |
270 |
# Passing a URL overrides the supplied branch path
|
|
271 |
revinfo = self.get_in_history('revno:2:tree2') |
|
272 |
self.assertNotEqual(self.tree.branch.base, revinfo.branch.base) |
|
273 |
self.assertEqual(self.tree2.branch.base, revinfo.branch.base) |
|
274 |
self.assertEqual(2, revinfo.revno) |
|
275 |
self.assertEqual('alt_r2', revinfo.rev_id) |
|
276 |
||
|
1948.4.32
by John Arbash Meinel
Clean up __repr__, as well as add tests that we can handle -r12:branch/ |
277 |
def test_int_with_branch(self): |
278 |
revinfo = self.get_in_history('2:tree2') |
|
279 |
self.assertNotEqual(self.tree.branch.base, revinfo.branch.base) |
|
280 |
self.assertEqual(self.tree2.branch.base, revinfo.branch.base) |
|
281 |
self.assertEqual(2, revinfo.revno) |
|
282 |
self.assertEqual('alt_r2', revinfo.rev_id) |
|
283 |
||
|
1948.4.7
by John Arbash Meinel
More revno: tests, now testing the branch/url parameter |
284 |
def test_with_url(self): |
285 |
url = self.get_url() + '/tree2' |
|
286 |
revinfo = self.get_in_history('revno:2:%s' % (url,)) |
|
287 |
self.assertNotEqual(self.tree.branch.base, revinfo.branch.base) |
|
288 |
self.assertEqual(self.tree2.branch.base, revinfo.branch.base) |
|
289 |
self.assertEqual(2, revinfo.revno) |
|
290 |
self.assertEqual('alt_r2', revinfo.rev_id) |
|
291 |
||
292 |
def test_negative_with_url(self): |
|
293 |
url = self.get_url() + '/tree2' |
|
294 |
revinfo = self.get_in_history('revno:-1:%s' % (url,)) |
|
295 |
self.assertNotEqual(self.tree.branch.base, revinfo.branch.base) |
|
296 |
self.assertEqual(self.tree2.branch.base, revinfo.branch.base) |
|
297 |
self.assertEqual(2, revinfo.revno) |
|
298 |
self.assertEqual('alt_r2', revinfo.rev_id) |
|
299 |
||
|
1948.4.22
by John Arbash Meinel
Refactor common code from integer revno handlers |
300 |
def test_different_history_lengths(self): |
301 |
# Make sure we use the revisions and offsets in the supplied branch
|
|
302 |
# not the ones in the original branch.
|
|
303 |
self.tree2.commit('three', rev_id='r3') |
|
304 |
self.assertInHistoryIs(3, 'r3', 'revno:3:tree2') |
|
305 |
self.assertInHistoryIs(3, 'r3', 'revno:-1:tree2') |
|
306 |
||
|
1948.4.7
by John Arbash Meinel
More revno: tests, now testing the branch/url parameter |
307 |
def test_invalid_branch(self): |
308 |
self.assertRaises(errors.NotBranchError, |
|
309 |
self.get_in_history, 'revno:-1:tree3') |
|
310 |
||
311 |
def test_invalid_revno_in_branch(self): |
|
312 |
self.tree.commit('three', rev_id='r3') |
|
313 |
self.assertInvalid('revno:3:tree2') |
|
|
1948.4.8
by John Arbash Meinel
Testing the revid: spec |
314 |
|
|
1948.4.16
by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes |
315 |
def test_revno_n_path(self): |
316 |
"""Old revno:N:path tests""" |
|
317 |
wta = self.make_branch_and_tree('a') |
|
318 |
ba = wta.branch |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
319 |
|
|
1948.4.16
by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes |
320 |
wta.commit('Commit one', rev_id='a@r-0-1') |
321 |
wta.commit('Commit two', rev_id='a@r-0-2') |
|
322 |
wta.commit('Commit three', rev_id='a@r-0-3') |
|
323 |
||
324 |
wtb = self.make_branch_and_tree('b') |
|
325 |
bb = wtb.branch |
|
326 |
||
327 |
wtb.commit('Commit one', rev_id='b@r-0-1') |
|
328 |
wtb.commit('Commit two', rev_id='b@r-0-2') |
|
329 |
wtb.commit('Commit three', rev_id='b@r-0-3') |
|
330 |
||
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
331 |
|
332 |
self.assertEqual((1, 'a@r-0-1'), |
|
333 |
spec_in_history('revno:1:a/', ba)) |
|
|
1948.4.16
by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes |
334 |
# The argument of in_history should be ignored since it is
|
335 |
# redundant with the path in the spec.
|
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
336 |
self.assertEqual((1, 'a@r-0-1'), |
337 |
spec_in_history('revno:1:a/', None)) |
|
338 |
self.assertEqual((1, 'a@r-0-1'), |
|
339 |
spec_in_history('revno:1:a/', bb)) |
|
340 |
self.assertEqual((2, 'b@r-0-2'), |
|
341 |
spec_in_history('revno:2:b/', None)) |
|
|
1948.4.16
by John Arbash Meinel
Move the tests into the associated tester, remove redundant tests, some small PEP8 changes |
342 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
343 |
def test_as_revision_id(self): |
|
3298.2.11
by Aaron Bentley
Update tests for null:, clea up slightly |
344 |
self.assertAsRevisionId('null:', '0') |
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
345 |
self.assertAsRevisionId('r1', '1') |
346 |
self.assertAsRevisionId('r2', '2') |
|
347 |
self.assertAsRevisionId('r1', '-2') |
|
348 |
self.assertAsRevisionId('r2', '-1') |
|
349 |
self.assertAsRevisionId('alt_r2', '1.1.1') |
|
350 |
||
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
351 |
def test_as_tree(self): |
352 |
tree = self.get_as_tree('0') |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
353 |
self.assertEqual(_mod_revision.NULL_REVISION, tree.get_revision_id()) |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
354 |
tree = self.get_as_tree('1') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
355 |
self.assertEqual('r1', tree.get_revision_id()) |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
356 |
tree = self.get_as_tree('2') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
357 |
self.assertEqual('r2', tree.get_revision_id()) |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
358 |
tree = self.get_as_tree('-2') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
359 |
self.assertEqual('r1', tree.get_revision_id()) |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
360 |
tree = self.get_as_tree('-1') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
361 |
self.assertEqual('r2', tree.get_revision_id()) |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
362 |
tree = self.get_as_tree('1.1.1') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
363 |
self.assertEqual('alt_r2', tree.get_revision_id()) |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
364 |
|
|
1948.4.8
by John Arbash Meinel
Testing the revid: spec |
365 |
|
366 |
class TestRevisionSpec_revid(TestRevisionSpec): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
367 |
|
|
1948.4.8
by John Arbash Meinel
Testing the revid: spec |
368 |
def test_in_history(self): |
369 |
# We should be able to access revisions that are directly
|
|
370 |
# in the history.
|
|
371 |
self.assertInHistoryIs(1, 'r1', 'revid:r1') |
|
372 |
self.assertInHistoryIs(2, 'r2', 'revid:r2') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
373 |
|
|
1948.4.8
by John Arbash Meinel
Testing the revid: spec |
374 |
def test_missing(self): |
|
3495.1.1
by John Arbash Meinel
Fix bug #239933, use the right exception for -c0 |
375 |
self.assertInvalid('revid:r3', invalid_as_revision_id=False) |
|
1948.4.8
by John Arbash Meinel
Testing the revid: spec |
376 |
|
377 |
def test_merged(self): |
|
378 |
"""We can reach revisions in the ancestry""" |
|
379 |
self.assertInHistoryIs(None, 'alt_r2', 'revid:alt_r2') |
|
380 |
||
381 |
def test_not_here(self): |
|
382 |
self.tree2.commit('alt third', rev_id='alt_r3') |
|
383 |
# It exists in tree2, but not in tree
|
|
|
3495.1.1
by John Arbash Meinel
Fix bug #239933, use the right exception for -c0 |
384 |
self.assertInvalid('revid:alt_r3', invalid_as_revision_id=False) |
|
1948.4.8
by John Arbash Meinel
Testing the revid: spec |
385 |
|
386 |
def test_in_repository(self): |
|
387 |
"""We can get any revision id in the repository""" |
|
388 |
# XXX: This may change in the future, but for now, it is true
|
|
389 |
self.tree2.commit('alt third', rev_id='alt_r3') |
|
|
5741.1.5
by Jelmer Vernooij
Have Branch.fetch() take a fetch_tags argument rather than a fetch_spec argument. |
390 |
self.tree.branch.fetch(self.tree2.branch, 'alt_r3') |
|
1948.4.8
by John Arbash Meinel
Testing the revid: spec |
391 |
self.assertInHistoryIs(None, 'alt_r3', 'revid:alt_r3') |
|
1948.4.9
by John Arbash Meinel
Cleanup and test last: |
392 |
|
|
2325.2.2
by Marien Zwart
Make the revid RevisionSpec always return a str object, not a unicode object. |
393 |
def test_unicode(self): |
394 |
"""We correctly convert a unicode ui string to an encoded revid.""" |
|
|
2325.2.4
by Marien Zwart
Rename rev_id to revision_id because HACKING says so. |
395 |
revision_id = u'\N{SNOWMAN}'.encode('utf-8') |
396 |
self.tree.commit('unicode', rev_id=revision_id) |
|
397 |
self.assertInHistoryIs(3, revision_id, u'revid:\N{SNOWMAN}') |
|
398 |
self.assertInHistoryIs(3, revision_id, 'revid:' + revision_id) |
|
|
2325.2.2
by Marien Zwart
Make the revid RevisionSpec always return a str object, not a unicode object. |
399 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
400 |
def test_as_revision_id(self): |
401 |
self.assertAsRevisionId('r1', 'revid:r1') |
|
402 |
self.assertAsRevisionId('r2', 'revid:r2') |
|
403 |
self.assertAsRevisionId('alt_r2', 'revid:alt_r2') |
|
404 |
||
|
1948.4.9
by John Arbash Meinel
Cleanup and test last: |
405 |
|
406 |
class TestRevisionSpec_last(TestRevisionSpec): |
|
407 |
||
408 |
def test_positive(self): |
|
409 |
self.assertInHistoryIs(2, 'r2', 'last:1') |
|
410 |
self.assertInHistoryIs(1, 'r1', 'last:2') |
|
|
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
411 |
self.assertInHistoryIs(0, 'null:', 'last:3') |
|
1948.4.9
by John Arbash Meinel
Cleanup and test last: |
412 |
|
413 |
def test_empty(self): |
|
414 |
self.assertInHistoryIs(2, 'r2', 'last:') |
|
415 |
||
416 |
def test_negative(self): |
|
417 |
self.assertInvalid('last:-1', |
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
418 |
extra='\nyou must supply a positive value') |
|
1948.4.9
by John Arbash Meinel
Cleanup and test last: |
419 |
|
420 |
def test_missing(self): |
|
421 |
self.assertInvalid('last:4') |
|
422 |
||
423 |
def test_no_history(self): |
|
424 |
tree = self.make_branch_and_tree('tree3') |
|
425 |
||
426 |
self.assertRaises(errors.NoCommits, |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
427 |
spec_in_history, 'last:', tree.branch) |
|
1948.4.9
by John Arbash Meinel
Cleanup and test last: |
428 |
|
429 |
def test_not_a_number(self): |
|
430 |
try: |
|
431 |
int('Y') |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
432 |
except ValueError as e: |
|
1948.4.9
by John Arbash Meinel
Cleanup and test last: |
433 |
pass
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
434 |
self.assertInvalid('last:Y', extra='\n' + str(e)) |
|
1948.4.10
by John Arbash Meinel
test the before: spec, currently asserting what seems to be buggy behavior |
435 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
436 |
def test_as_revision_id(self): |
437 |
self.assertAsRevisionId('r2', 'last:1') |
|
438 |
self.assertAsRevisionId('r1', 'last:2') |
|
439 |
||
|
1948.4.10
by John Arbash Meinel
test the before: spec, currently asserting what seems to be buggy behavior |
440 |
|
441 |
class TestRevisionSpec_before(TestRevisionSpec): |
|
442 |
||
443 |
def test_int(self): |
|
444 |
self.assertInHistoryIs(1, 'r1', 'before:2') |
|
445 |
self.assertInHistoryIs(1, 'r1', 'before:-1') |
|
446 |
||
447 |
def test_before_one(self): |
|
|
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
448 |
self.assertInHistoryIs(0, 'null:', 'before:1') |
|
1948.4.10
by John Arbash Meinel
test the before: spec, currently asserting what seems to be buggy behavior |
449 |
|
450 |
def test_before_none(self): |
|
|
1948.4.13
by John Arbash Meinel
Going before:0 is an error, and if you are on another history, use the leftmost parent |
451 |
self.assertInvalid('before:0', |
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
452 |
extra='\ncannot go before the null: revision') |
|
1948.4.10
by John Arbash Meinel
test the before: spec, currently asserting what seems to be buggy behavior |
453 |
|
454 |
def test_revid(self): |
|
455 |
self.assertInHistoryIs(1, 'r1', 'before:revid:r2') |
|
456 |
||
457 |
def test_last(self): |
|
458 |
self.assertInHistoryIs(1, 'r1', 'before:last:1') |
|
459 |
||
460 |
def test_alt_revid(self): |
|
|
1948.4.13
by John Arbash Meinel
Going before:0 is an error, and if you are on another history, use the leftmost parent |
461 |
# This will grab the left-most ancestor for alternate histories
|
462 |
self.assertInHistoryIs(1, 'r1', 'before:revid:alt_r2') |
|
|
1948.4.11
by John Arbash Meinel
Update and test the tag: spec |
463 |
|
|
1948.4.14
by John Arbash Meinel
Test the code path for a no-parent alternate history |
464 |
def test_alt_no_parents(self): |
465 |
new_tree = self.make_branch_and_tree('new_tree') |
|
466 |
new_tree.commit('first', rev_id='new_r1') |
|
|
5741.1.5
by Jelmer Vernooij
Have Branch.fetch() take a fetch_tags argument rather than a fetch_spec argument. |
467 |
self.tree.branch.fetch(new_tree.branch, 'new_r1') |
|
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
468 |
self.assertInHistoryIs(0, 'null:', 'before:revid:new_r1') |
|
1948.4.14
by John Arbash Meinel
Test the code path for a no-parent alternate history |
469 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
470 |
def test_as_revision_id(self): |
471 |
self.assertAsRevisionId('r1', 'before:revid:r2') |
|
472 |
self.assertAsRevisionId('r1', 'before:2') |
|
473 |
self.assertAsRevisionId('r1', 'before:1.1.1') |
|
474 |
self.assertAsRevisionId('r1', 'before:revid:alt_r2') |
|
475 |
||
|
1948.4.11
by John Arbash Meinel
Update and test the tag: spec |
476 |
|
477 |
class TestRevisionSpec_tag(TestRevisionSpec): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
478 |
|
|
2220.2.3
by Martin Pool
Add tag: revision namespace. |
479 |
def make_branch_and_tree(self, relpath): |
480 |
# override format as the default one may not support tags
|
|
|
3031.3.1
by Robert Collins
Remove the unneeded ExperimentalBranch class. |
481 |
return TestRevisionSpec.make_branch_and_tree( |
482 |
self, relpath, format='dirstate-tags') |
|
|
2220.2.3
by Martin Pool
Add tag: revision namespace. |
483 |
|
484 |
def test_from_string_tag(self): |
|
485 |
spec = RevisionSpec.from_string('tag:bzr-0.14') |
|
486 |
self.assertIsInstance(spec, RevisionSpec_tag) |
|
487 |
self.assertEqual(spec.spec, 'bzr-0.14') |
|
488 |
||
489 |
def test_lookup_tag(self): |
|
|
2220.2.20
by Martin Pool
Tag methods now available through Branch.tags.add_tag, etc |
490 |
self.tree.branch.tags.set_tag('bzr-0.14', 'r1') |
|
2220.2.3
by Martin Pool
Add tag: revision namespace. |
491 |
self.assertInHistoryIs(1, 'r1', 'tag:bzr-0.14') |
|
3298.2.11
by Aaron Bentley
Update tests for null:, clea up slightly |
492 |
self.tree.branch.tags.set_tag('null_rev', 'null:') |
493 |
self.assertInHistoryIs(0, 'null:', 'tag:null_rev') |
|
|
2220.2.3
by Martin Pool
Add tag: revision namespace. |
494 |
|
495 |
def test_failed_lookup(self): |
|
496 |
# tags that don't exist give a specific message: arguably we should
|
|
497 |
# just give InvalidRevisionSpec but I think this is more helpful
|
|
498 |
self.assertRaises(errors.NoSuchTag, |
|
499 |
self.get_in_history, |
|
500 |
'tag:some-random-tag') |
|
|
1948.4.12
by John Arbash Meinel
Some tests for the date: spec |
501 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
502 |
def test_as_revision_id(self): |
503 |
self.tree.branch.tags.set_tag('my-tag', 'r2') |
|
|
3298.2.11
by Aaron Bentley
Update tests for null:, clea up slightly |
504 |
self.tree.branch.tags.set_tag('null_rev', 'null:') |
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
505 |
self.assertAsRevisionId('r2', 'tag:my-tag') |
|
3298.2.11
by Aaron Bentley
Update tests for null:, clea up slightly |
506 |
self.assertAsRevisionId('null:', 'tag:null_rev') |
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
507 |
self.assertAsRevisionId('r1', 'before:tag:my-tag') |
508 |
||
|
1948.4.12
by John Arbash Meinel
Some tests for the date: spec |
509 |
|
510 |
class TestRevisionSpec_date(TestRevisionSpec): |
|
511 |
||
512 |
def setUp(self): |
|
513 |
super(TestRevisionSpec, self).setUp() |
|
514 |
||
515 |
new_tree = self.make_branch_and_tree('new_tree') |
|
516 |
new_tree.commit('Commit one', rev_id='new_r1', |
|
517 |
timestamp=time.time() - 60*60*24) |
|
518 |
new_tree.commit('Commit two', rev_id='new_r2') |
|
519 |
new_tree.commit('Commit three', rev_id='new_r3') |
|
520 |
||
521 |
self.tree = new_tree |
|
522 |
||
523 |
def test_tomorrow(self): |
|
524 |
self.assertInvalid('date:tomorrow') |
|
525 |
||
526 |
def test_today(self): |
|
527 |
self.assertInHistoryIs(2, 'new_r2', 'date:today') |
|
528 |
self.assertInHistoryIs(1, 'new_r1', 'before:date:today') |
|
529 |
||
530 |
def test_yesterday(self): |
|
531 |
self.assertInHistoryIs(1, 'new_r1', 'date:yesterday') |
|
532 |
||
533 |
def test_invalid(self): |
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
534 |
self.assertInvalid('date:foobar', extra='\ninvalid date') |
|
1948.4.12
by John Arbash Meinel
Some tests for the date: spec |
535 |
# You must have '-' between year/month/day
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
536 |
self.assertInvalid('date:20040404', extra='\ninvalid date') |
|
1948.4.12
by John Arbash Meinel
Some tests for the date: spec |
537 |
# Need 2 digits for each date piece
|
|
1948.4.15
by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable |
538 |
self.assertInvalid('date:2004-4-4', extra='\ninvalid date') |
|
1948.4.12
by John Arbash Meinel
Some tests for the date: spec |
539 |
|
540 |
def test_day(self): |
|
541 |
now = datetime.datetime.now() |
|
542 |
self.assertInHistoryIs(2, 'new_r2', |
|
543 |
'date:%04d-%02d-%02d' % (now.year, now.month, now.day)) |
|
|
1948.4.17
by John Arbash Meinel
Update tests for ancestor: spec |
544 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
545 |
def test_as_revision_id(self): |
546 |
self.assertAsRevisionId('new_r2', 'date:today') |
|
547 |
||
|
1948.4.17
by John Arbash Meinel
Update tests for ancestor: spec |
548 |
|
549 |
class TestRevisionSpec_ancestor(TestRevisionSpec): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
550 |
|
|
1948.4.17
by John Arbash Meinel
Update tests for ancestor: spec |
551 |
def test_non_exact_branch(self): |
552 |
# It seems better to require an exact path to the branch
|
|
553 |
# Branch.open() rather than using Branch.open_containing()
|
|
554 |
self.assertRaises(errors.NotBranchError, |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
555 |
self.get_in_history, 'ancestor:tree2/a') |
|
1948.4.17
by John Arbash Meinel
Update tests for ancestor: spec |
556 |
|
557 |
def test_simple(self): |
|
558 |
# Common ancestor of trees is 'alt_r2'
|
|
559 |
self.assertInHistoryIs(None, 'alt_r2', 'ancestor:tree2') |
|
560 |
||
561 |
# Going the other way, we get a valid revno
|
|
562 |
tmp = self.tree |
|
563 |
self.tree = self.tree2 |
|
564 |
self.tree2 = tmp |
|
565 |
self.assertInHistoryIs(2, 'alt_r2', 'ancestor:tree') |
|
566 |
||
567 |
def test_self(self): |
|
568 |
self.assertInHistoryIs(2, 'r2', 'ancestor:tree') |
|
569 |
||
570 |
def test_unrelated(self): |
|
571 |
new_tree = self.make_branch_and_tree('new_tree') |
|
572 |
||
573 |
new_tree.commit('Commit one', rev_id='new_r1') |
|
574 |
new_tree.commit('Commit two', rev_id='new_r2') |
|
575 |
new_tree.commit('Commit three', rev_id='new_r3') |
|
576 |
||
577 |
# With no common ancestor, we should raise another user error
|
|
578 |
self.assertRaises(errors.NoCommonAncestor, |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
579 |
self.get_in_history, 'ancestor:new_tree') |
|
1948.4.17
by John Arbash Meinel
Update tests for ancestor: spec |
580 |
|
581 |
def test_no_commits(self): |
|
582 |
new_tree = self.make_branch_and_tree('new_tree') |
|
583 |
self.assertRaises(errors.NoCommits, |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
584 |
spec_in_history, 'ancestor:new_tree', |
585 |
self.tree.branch) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
586 |
|
|
1948.4.17
by John Arbash Meinel
Update tests for ancestor: spec |
587 |
self.assertRaises(errors.NoCommits, |
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
588 |
spec_in_history, 'ancestor:tree', |
589 |
new_tree.branch) |
|
|
1948.4.18
by John Arbash Meinel
Update branch: spec and tests |
590 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
591 |
def test_as_revision_id(self): |
592 |
self.assertAsRevisionId('alt_r2', 'ancestor:tree2') |
|
593 |
||
|
3984.1.1
by Daniel Watkins
Added test. |
594 |
def test_default(self): |
595 |
# We don't have a parent to default to
|
|
596 |
self.assertRaises(errors.NotBranchError, self.get_in_history, |
|
597 |
'ancestor:') |
|
598 |
||
599 |
# Create a branch with a parent to default to
|
|
600 |
tree3 = self.tree.bzrdir.sprout('tree3').open_workingtree() |
|
601 |
tree3.commit('foo', rev_id='r3') |
|
602 |
self.tree = tree3 |
|
603 |
self.assertInHistoryIs(2, 'r2', 'ancestor:') |
|
604 |
||
|
1948.4.18
by John Arbash Meinel
Update branch: spec and tests |
605 |
|
606 |
class TestRevisionSpec_branch(TestRevisionSpec): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
607 |
|
|
1948.4.18
by John Arbash Meinel
Update branch: spec and tests |
608 |
def test_non_exact_branch(self): |
609 |
# It seems better to require an exact path to the branch
|
|
610 |
# Branch.open() rather than using Branch.open_containing()
|
|
611 |
self.assertRaises(errors.NotBranchError, |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
612 |
self.get_in_history, 'branch:tree2/a') |
|
1948.4.18
by John Arbash Meinel
Update branch: spec and tests |
613 |
|
614 |
def test_simple(self): |
|
615 |
self.assertInHistoryIs(None, 'alt_r2', 'branch:tree2') |
|
616 |
||
617 |
def test_self(self): |
|
618 |
self.assertInHistoryIs(2, 'r2', 'branch:tree') |
|
619 |
||
620 |
def test_unrelated(self): |
|
621 |
new_tree = self.make_branch_and_tree('new_tree') |
|
622 |
||
623 |
new_tree.commit('Commit one', rev_id='new_r1') |
|
624 |
new_tree.commit('Commit two', rev_id='new_r2') |
|
625 |
new_tree.commit('Commit three', rev_id='new_r3') |
|
626 |
||
627 |
self.assertInHistoryIs(None, 'new_r3', 'branch:new_tree') |
|
628 |
||
629 |
# XXX: Right now, we use fetch() to make sure the remote revisions
|
|
630 |
# have been pulled into the local branch. We may change that
|
|
631 |
# behavior in the future.
|
|
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
632 |
self.assertTrue(self.tree.branch.repository.has_revision('new_r3')) |
|
1948.4.18
by John Arbash Meinel
Update branch: spec and tests |
633 |
|
634 |
def test_no_commits(self): |
|
635 |
new_tree = self.make_branch_and_tree('new_tree') |
|
636 |
self.assertRaises(errors.NoCommits, |
|
|
1948.4.33
by John Arbash Meinel
Switch from get_revision_spec() to RevisionSpec.from_string() (as advised by Martin) |
637 |
self.get_in_history, 'branch:new_tree') |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
638 |
self.assertRaises(errors.NoCommits, |
639 |
self.get_as_tree, 'branch:new_tree') |
|
|
1551.10.32
by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs |
640 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
641 |
def test_as_revision_id(self): |
642 |
self.assertAsRevisionId('alt_r2', 'branch:tree2') |
|
643 |
||
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
644 |
def test_as_tree(self): |
645 |
tree = self.get_as_tree('branch:tree', self.tree2) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
646 |
self.assertEqual('r2', tree.get_revision_id()) |
|
3655.3.1
by Lukáš Lalinský
Fix `bzr st -rbranch:PATH_TO_BRANCH` |
647 |
self.assertFalse(self.tree2.branch.repository.has_revision('r2')) |
648 |
||
|
1551.10.32
by Aaron Bentley
Add submit: specifier, for merge-directive-like diffs |
649 |
|
650 |
class TestRevisionSpec_submit(TestRevisionSpec): |
|
651 |
||
652 |
def test_submit_branch(self): |
|
653 |
# Common ancestor of trees is 'alt_r2'
|
|
654 |
self.assertRaises(errors.NoSubmitBranch, self.get_in_history, |
|
655 |
'submit:') |
|
656 |
self.tree.branch.set_parent('../tree2') |
|
657 |
self.assertInHistoryIs(None, 'alt_r2', 'submit:') |
|
658 |
self.tree.branch.set_parent('bogus') |
|
659 |
self.assertRaises(errors.NotBranchError, self.get_in_history, |
|
660 |
'submit:') |
|
661 |
# submit branch overrides parent branch
|
|
662 |
self.tree.branch.set_submit_branch('tree2') |
|
663 |
self.assertInHistoryIs(None, 'alt_r2', 'submit:') |
|
|
3298.2.3
by John Arbash Meinel
Add tests that all RevisionSpecs implement in_branch(b, needs_revno) |
664 |
|
|
3298.2.4
by John Arbash Meinel
Introduce as_revision_id() as a function instead of in_branch(need_revno=False) |
665 |
def test_as_revision_id(self): |
666 |
self.tree.branch.set_submit_branch('tree2') |
|
667 |
self.assertAsRevisionId('alt_r2', 'branch:tree2') |
|
|
5365.6.4
by Aaron Bentley
Implement mainline revision spec. |
668 |
|
669 |
||
670 |
class TestRevisionSpec_mainline(TestRevisionSpec): |
|
671 |
||
672 |
def test_as_revision_id(self): |
|
673 |
self.assertAsRevisionId('r1', 'mainline:1') |
|
674 |
self.assertAsRevisionId('r2', 'mainline:1.1.1') |
|
675 |
self.assertAsRevisionId('r2', 'mainline:revid:alt_r2') |
|
676 |
spec = RevisionSpec.from_string('mainline:revid:alt_r22') |
|
677 |
e = self.assertRaises(errors.InvalidRevisionSpec, |
|
678 |
spec.as_revision_id, self.tree.branch) |
|
679 |
self.assertContainsRe(str(e), |
|
680 |
"Requested revision: 'mainline:revid:alt_r22' does not exist in"
|
|
681 |
" branch: ") |
|
682 |
||
683 |
def test_in_history(self): |
|
684 |
self.assertInHistoryIs(2, 'r2', 'mainline:revid:alt_r2') |
|
|
5365.6.6
by Aaron Bentley
Implement 'annotate' revision-id. |
685 |
|
686 |
||
687 |
class TestRevisionSpec_annotate(TestRevisionSpec): |
|
688 |
||
689 |
def setUp(self): |
|
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
690 |
super(TestRevisionSpec_annotate, self).setUp() |
|
5365.6.6
by Aaron Bentley
Implement 'annotate' revision-id. |
691 |
self.tree = self.make_branch_and_tree('annotate-tree') |
692 |
self.build_tree_contents([('annotate-tree/file1', '1\n')]) |
|
693 |
self.tree.add('file1') |
|
694 |
self.tree.commit('r1', rev_id='r1') |
|
695 |
self.build_tree_contents([('annotate-tree/file1', '2\n1\n')]) |
|
696 |
self.tree.commit('r2', rev_id='r2') |
|
697 |
self.build_tree_contents([('annotate-tree/file1', '2\n1\n3\n')]) |
|
698 |
||
699 |
def test_as_revision_id_r1(self): |
|
700 |
self.assertAsRevisionId('r1', 'annotate:annotate-tree/file1:2') |
|
701 |
||
702 |
def test_as_revision_id_r2(self): |
|
703 |
self.assertAsRevisionId('r2', 'annotate:annotate-tree/file1:1') |
|
704 |
||
705 |
def test_as_revision_id_uncommitted(self): |
|
706 |
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:3') |
|
707 |
e = self.assertRaises(errors.InvalidRevisionSpec, |
|
708 |
spec.as_revision_id, self.tree.branch) |
|
709 |
self.assertContainsRe(str(e), |
|
710 |
r"Requested revision: \'annotate:annotate-tree/file1:3\' does not" |
|
711 |
" exist in branch: .*\nLine 3 has not been committed.") |
|
712 |
||
|
5365.6.10
by Andrew Bennetts
Fix typo in test method name. |
713 |
def test_non_existent_line(self): |
|
5365.6.6
by Aaron Bentley
Implement 'annotate' revision-id. |
714 |
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:4') |
715 |
e = self.assertRaises(errors.InvalidRevisionSpec, |
|
716 |
spec.as_revision_id, self.tree.branch) |
|
717 |
self.assertContainsRe(str(e), |
|
718 |
r"Requested revision: \'annotate:annotate-tree/file1:4\' does not" |
|
719 |
" exist in branch: .*\nNo such line: 4") |
|
720 |
||
721 |
def test_invalid_line(self): |
|
722 |
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:q') |
|
723 |
e = self.assertRaises(errors.InvalidRevisionSpec, |
|
724 |
spec.as_revision_id, self.tree.branch) |
|
725 |
self.assertContainsRe(str(e), |
|
726 |
r"Requested revision: \'annotate:annotate-tree/file1:q\' does not" |
|
727 |
" exist in branch: .*\nNo such line: q") |
|
728 |
||
729 |
def test_no_such_file(self): |
|
730 |
spec = RevisionSpec.from_string('annotate:annotate-tree/file2:1') |
|
731 |
e = self.assertRaises(errors.InvalidRevisionSpec, |
|
732 |
spec.as_revision_id, self.tree.branch) |
|
733 |
self.assertContainsRe(str(e), |
|
734 |
r"Requested revision: \'annotate:annotate-tree/file2:1\' does not" |
|
735 |
" exist in branch: .*\nFile 'file2' is not versioned") |
|
736 |
||
737 |
def test_no_such_file_with_colon(self): |
|
738 |
spec = RevisionSpec.from_string('annotate:annotate-tree/fi:le2:1') |
|
739 |
e = self.assertRaises(errors.InvalidRevisionSpec, |
|
740 |
spec.as_revision_id, self.tree.branch) |
|
741 |
self.assertContainsRe(str(e), |
|
742 |
r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not" |
|
743 |
" exist in branch: .*\nFile 'fi:le2' is not versioned") |