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