5273.1.8
by Vincent Ladeuil
Merge bzr.dev into cleanup |
1 |
# Copyright (C) 2005-2010 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
16 |
|
17 |
import os |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
18 |
|
19 |
from bzrlib.errors import BzrCommandError, NoSuchRevision |
|
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
20 |
from bzrlib.tests import TestCaseWithTransport |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
21 |
from bzrlib.workingtree import WorkingTree |
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
22 |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
23 |
|
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
24 |
class TestRevisionInfo(TestCaseWithTransport): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
25 |
|
5283.4.4
by Martin Pool
Remove obsolete test helper; add a new local one |
26 |
def check_output(self, output, *args): |
27 |
"""Verify that the expected output matches what bzr says.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
28 |
|
1185.1.29
by Robert Collins
merge merge tweaks from aaron, which includes latest .dev |
29 |
The output is supplied first, so that you can supply a variable
|
30 |
number of arguments to bzr.
|
|
31 |
"""
|
|
5283.4.4
by Martin Pool
Remove obsolete test helper; add a new local one |
32 |
self.assertEquals(self.run_bzr(*args)[0], output) |
1185.1.29
by Robert Collins
merge merge tweaks from aaron, which includes latest .dev |
33 |
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
34 |
def test_revision_info(self): |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
35 |
"""Test that 'bzr revision-info' reports the correct thing."""
|
36 |
wt = self.make_branch_and_tree('.') |
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
37 |
|
2512.2.4
by Matthew Fuller
Rewrite revision-info blackbox tests to test: |
38 |
# Make history with a non-mainline rev
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
39 |
wt.commit('Commit one', rev_id='a@r-0-1') |
2512.2.4
by Matthew Fuller
Rewrite revision-info blackbox tests to test: |
40 |
wt.commit('Commit two', rev_id='a@r-0-1.1.1') |
41 |
wt.set_parent_ids(['a@r-0-1', 'a@r-0-1.1.1']) |
|
42 |
wt.branch.set_last_revision_info(1, 'a@r-0-1') |
|
43 |
wt.commit('Commit three', rev_id='a@r-0-2') |
|
44 |
||
45 |
# This is expected to work even if the working tree is removed
|
|
46 |
wt.bzrdir.destroy_workingtree() |
|
47 |
||
48 |
# Expected return values
|
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
49 |
values = { |
4409.2.4
by Matthew Fuller
Fix up tests to work with new alignment. |
50 |
'1' : '1 a@r-0-1\n', |
2512.2.4
by Matthew Fuller
Rewrite revision-info blackbox tests to test: |
51 |
'1.1.1': '1.1.1 a@r-0-1.1.1\n', |
4409.2.4
by Matthew Fuller
Fix up tests to work with new alignment. |
52 |
'2' : '2 a@r-0-2\n' |
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
53 |
}
|
54 |
||
2512.2.4
by Matthew Fuller
Rewrite revision-info blackbox tests to test: |
55 |
# Make sure with no arg it defaults to the head
|
56 |
self.check_output(values['2'], 'revision-info') |
|
57 |
||
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
58 |
# Check the results of just specifying a numeric revision
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
59 |
self.check_output(values['1'], 'revision-info 1') |
60 |
self.check_output(values['1.1.1'], 'revision-info 1.1.1') |
|
61 |
self.check_output(values['2'], 'revision-info 2') |
|
62 |
self.check_output(values['1']+values['2'], 'revision-info 1 2') |
|
4409.1.21
by Vincent Ladeuil
Fix failing test. |
63 |
self.check_output(' '+values['1']+ |
64 |
values['1.1.1']+ |
|
4409.2.4
by Matthew Fuller
Fix up tests to work with new alignment. |
65 |
' '+values['2'], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
66 |
'revision-info 1 1.1.1 2') |
67 |
self.check_output(values['2']+values['1'], 'revision-info 2 1') |
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
68 |
|
69 |
# Check as above, only using the '--revision' syntax
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
70 |
|
71 |
self.check_output(values['1'], 'revision-info -r 1') |
|
72 |
self.check_output(values['1.1.1'], 'revision-info --revision 1.1.1') |
|
73 |
self.check_output(values['2'], 'revision-info -r 2') |
|
74 |
self.check_output(values['1']+values['2'], 'revision-info -r 1..2') |
|
4409.1.21
by Vincent Ladeuil
Fix failing test. |
75 |
self.check_output(' '+values['1']+ |
76 |
values['1.1.1']+ |
|
4409.2.4
by Matthew Fuller
Fix up tests to work with new alignment. |
77 |
' '+values['2'], |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
78 |
'revision-info -r 1..1.1.1..2') |
79 |
self.check_output(values['2']+values['1'], 'revision-info -r 2..1') |
|
1185.5.4
by John Arbash Meinel
Updated bzr revision-info, created tests. |
80 |
|
81 |
# Now try some more advanced revision specifications
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
82 |
|
83 |
self.check_output(values['1'], 'revision-info -r revid:a@r-0-1') |
|
84 |
self.check_output(values['1.1.1'], |
|
85 |
'revision-info --revision revid:a@r-0-1.1.1') |
|
3886.1.1
by Michael Hudson
support -d in the revision-info command |
86 |
|
87 |
def test_revision_info_explicit_branch_dir(self): |
|
88 |
"""Test that 'bzr revision-info' honors the '-d' option."""
|
|
89 |
wt = self.make_branch_and_tree('branch') |
|
90 |
||
91 |
wt.commit('Commit one', rev_id='a@r-0-1') |
|
4409.2.4
by Matthew Fuller
Fix up tests to work with new alignment. |
92 |
self.check_output('1 a@r-0-1\n', 'revision-info -d branch') |
4409.1.4
by Matthew Fuller
Add tests for revision-info --tree. |
93 |
|
94 |
def test_revision_info_tree(self): |
|
95 |
# Make branch and checkout
|
|
96 |
wt = self.make_branch_and_tree('branch') |
|
97 |
wt.commit('Commit one', rev_id='a@r-0-1') |
|
98 |
||
99 |
# Make checkout and move the branch forward
|
|
4409.1.8
by John Arbash Meinel
Small tweaks to to the tests for --tree support. |
100 |
wt.branch.create_checkout('checkout', lightweight=True) |
4409.1.4
by Matthew Fuller
Add tests for revision-info --tree. |
101 |
wt.commit('Commit two', rev_id='a@r-0-2') |
102 |
||
103 |
# Make sure the checkout gives the right answer for branch and
|
|
104 |
# tree
|
|
4409.1.18
by Matthew Fuller
Fix some revision-info tests for the new alignment output. |
105 |
self.check_output('2 a@r-0-2\n', 'revision-info -d checkout') |
106 |
self.check_output('1 a@r-0-1\n', 'revision-info --tree -d checkout') |
|
4409.1.10
by John Arbash Meinel
Clean up 'bzr revision-info' to support revision not in the branch history. |
107 |
|
4409.1.13
by Matthew Fuller
Add test for revision-info --tree on a dir without a tree. |
108 |
def test_revision_info_tree_no_working_tree(self): |
109 |
# Make branch with no tree
|
|
110 |
b = self.make_branch('branch') |
|
111 |
||
112 |
# Try getting the --tree revision-info
|
|
113 |
out,err = self.run_bzr('revision-info --tree -d branch', retcode=3) |
|
114 |
self.assertEqual('', out) |
|
115 |
self.assertEqual('bzr: ERROR: No WorkingTree exists for "branch".\n', |
|
116 |
err) |
|
117 |
||
4409.1.10
by John Arbash Meinel
Clean up 'bzr revision-info' to support revision not in the branch history. |
118 |
def test_revision_info_not_in_history(self): |
119 |
builder = self.make_branch_builder('branch') |
|
120 |
builder.start_series() |
|
121 |
builder.build_snapshot('A-id', None, [ |
|
122 |
('add', ('', 'root-id', 'directory', None))]) |
|
123 |
builder.build_snapshot('B-id', ['A-id'], []) |
|
124 |
builder.build_snapshot('C-id', ['A-id'], []) |
|
125 |
builder.finish_series() |
|
4409.1.18
by Matthew Fuller
Fix some revision-info tests for the new alignment output. |
126 |
self.check_output(' 1 A-id\n??? B-id\n 2 C-id\n', |
4409.1.10
by John Arbash Meinel
Clean up 'bzr revision-info' to support revision not in the branch history. |
127 |
'revision-info -d branch'
|
128 |
' revid:A-id revid:B-id revid:C-id') |