5273.1.8
by Vincent Ladeuil
Merge bzr.dev into cleanup |
1 |
# Copyright (C) 2007-2010 Canonical Ltd
|
1551.13.18
by Aaron Bentley
Add copyright notice |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1551.13.18
by Aaron Bentley
Add copyright notice |
16 |
|
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
17 |
|
18 |
from bzrlib.tests import TestCaseWithTransport |
|
19 |
||
20 |
||
21 |
class TestCatRevision(TestCaseWithTransport): |
|
1551.13.17
by Aaron Bentley
Move cat-revision tests out of test_revision_info |
22 |
|
23 |
def test_cat_unicode_revision(self): |
|
1551.13.16
by Aaron Bentley
Fix cat-revision REVISION |
24 |
tree = self.make_branch_and_tree('.') |
25 |
tree.commit('This revision', rev_id='abcd') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
26 |
output, errors = self.run_bzr(['cat-revision', u'abcd']) |
1551.13.16
by Aaron Bentley
Fix cat-revision REVISION |
27 |
self.assertContainsRe(output, 'This revision') |
28 |
self.assertEqual('', errors) |
|
1551.13.17
by Aaron Bentley
Move cat-revision tests out of test_revision_info |
29 |
|
30 |
def test_cat_revision(self): |
|
31 |
"""Test bzr cat-revision.
|
|
32 |
"""
|
|
33 |
wt = self.make_branch_and_tree('.') |
|
34 |
r = wt.branch.repository |
|
35 |
||
36 |
wt.commit('Commit one', rev_id='a@r-0-1') |
|
37 |
wt.commit('Commit two', rev_id='a@r-0-2') |
|
38 |
wt.commit('Commit three', rev_id='a@r-0-3') |
|
39 |
||
5035.2.1
by Jelmer Vernooij
Repository.get_revision_xml() has been removed. |
40 |
r.lock_read() |
41 |
try: |
|
42 |
revs = {} |
|
43 |
for i in (1, 2, 3): |
|
44 |
revid = "a@r-0-%d" % i |
|
45 |
stream = r.revisions.get_record_stream([(revid,)], 'unordered', |
|
46 |
False) |
|
47 |
revs[i] = stream.next().get_bytes_as('fulltext') |
|
48 |
finally: |
|
49 |
r.unlock() |
|
1551.13.17
by Aaron Bentley
Move cat-revision tests out of test_revision_info |
50 |
|
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
51 |
for i in [1, 2, 3]: |
52 |
self.assertEqual(revs[i], |
|
53 |
self.run_bzr('cat-revision -r revid:a@r-0-%d' % i)[0]) |
|
54 |
self.assertEqual(revs[i], |
|
55 |
self.run_bzr('cat-revision a@r-0-%d' % i)[0]) |
|
56 |
self.assertEqual(revs[i], |
|
57 |
self.run_bzr('cat-revision -r %d' % i)[0]) |
|
3668.4.1
by Jelmer Vernooij
Show proper error rather than traceback when an unknown revision id is specified to bzr cat-revision. |
58 |
|
59 |
def test_cat_no_such_revid(self): |
|
60 |
tree = self.make_branch_and_tree('.') |
|
61 |
err = self.run_bzr('cat-revision abcd', retcode=3)[1] |
|
62 |
self.assertContainsRe(err, 'The repository .* contains no revision abcd.') |
|
63 |
||
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
64 |
def test_cat_revision_directory(self): |
65 |
"""Test --directory option"""
|
|
66 |
tree = self.make_branch_and_tree('a') |
|
67 |
tree.commit('This revision', rev_id='abcd') |
|
68 |
output, errors = self.run_bzr(['cat-revision', '-d', 'a', u'abcd']) |
|
69 |
self.assertContainsRe(output, 'This revision') |
|
70 |
self.assertEqual('', errors) |
|
5616.4.1
by Jelmer Vernooij
'bzr cat-revision' no longer requires a working tree. |
71 |
|
72 |
def test_cat_tree_less_branch(self): |
|
73 |
tree = self.make_branch_and_tree('.') |
|
74 |
tree.commit('This revision', rev_id='abcd') |
|
75 |
tree.bzrdir.destroy_workingtree() |
|
76 |
output, errors = self.run_bzr(['cat-revision', '-d', 'a', u'abcd']) |
|
77 |
self.assertContainsRe(output, 'This revision') |
|
78 |
self.assertEqual('', errors) |