bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
2052.3.2
by John Arbash Meinel
 Change Copyright .. by Canonical to Copyright ... Canonical  | 
1  | 
# Copyright (C) 2005 Canonical Ltd
 | 
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
2  | 
# -*- coding: utf-8 -*-
 | 
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
3  | 
#
 | 
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
4  | 
# This program is free software; you can redistribute it and/or modify
 | 
5  | 
# it under the terms of the GNU General Public License as published by
 | 
|
6  | 
# the Free Software Foundation; either version 2 of the License, or
 | 
|
7  | 
# (at your option) any later version.
 | 
|
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
8  | 
#
 | 
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
9  | 
# This program is distributed in the hope that it will be useful,
 | 
10  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
11  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
12  | 
# GNU General Public License for more details.
 | 
|
| 
1887.1.1
by Adeodato Simó
 Do not separate paragraphs in the copyright statement with blank lines,  | 
13  | 
#
 | 
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
14  | 
# You should have received a copy of the GNU General Public License
 | 
15  | 
# along with this program; if not, write to the Free Software
 | 
|
16  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
17  | 
||
18  | 
||
19  | 
"""Black-box tests for bzr cat.
 | 
|
20  | 
"""
 | 
|
21  | 
||
22  | 
import os  | 
|
23  | 
||
| 
2158.1.1
by Wouter van Heyst
 Fix #73500 mostly by catching a NotLocalUrl exception in cmd_cat.  | 
24  | 
from bzrlib.tests.blackbox import TestCaseWithTransport  | 
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
25  | 
|
| 
2158.1.1
by Wouter van Heyst
 Fix #73500 mostly by catching a NotLocalUrl exception in cmd_cat.  | 
26  | 
class TestCat(TestCaseWithTransport):  | 
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
27  | 
|
28  | 
def test_cat(self):  | 
|
29  | 
||
30  | 
def bzr(*args, **kwargs):  | 
|
| 
2178.4.1
by Alexander Belchenko
 Provide tests to illustrate bug #55276 on win32.  | 
31  | 
return self.run_bzr_subprocess(*args, **kwargs)[0]  | 
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
32  | 
|
| 
1907.4.3
by Matthieu Moy
 bzr cat now works nicely with revno:N:path too  | 
33  | 
os.mkdir('branch')  | 
34  | 
os.chdir('branch')  | 
|
| 
1185.50.9
by John Arbash Meinel
 [bug 3632] Matthieu Moy- bzr cat should default to last revision  | 
35  | 
bzr('init')  | 
36  | 
open('a', 'wb').write('foo\n')  | 
|
37  | 
bzr('add', 'a')  | 
|
38  | 
||
39  | 
        # 'bzr cat' without an option should cat the last revision
 | 
|
40  | 
bzr('cat', 'a', retcode=3)  | 
|
41  | 
||
42  | 
bzr('commit', '-m', '1')  | 
|
43  | 
open('a', 'wb').write('baz\n')  | 
|
44  | 
||
45  | 
self.assertEquals(bzr('cat', 'a'), 'foo\n')  | 
|
46  | 
||
47  | 
bzr('commit', '-m', '2')  | 
|
48  | 
self.assertEquals(bzr('cat', 'a'), 'baz\n')  | 
|
49  | 
self.assertEquals(bzr('cat', 'a', '-r', '1'), 'foo\n')  | 
|
50  | 
self.assertEquals(bzr('cat', 'a', '-r', '-1'), 'baz\n')  | 
|
51  | 
||
52  | 
rev_id = bzr('revision-history').strip().split('\n')[-1]  | 
|
53  | 
||
54  | 
self.assertEquals(bzr('cat', 'a', '-r', 'revid:%s' % rev_id), 'baz\n')  | 
|
| 
1907.4.3
by Matthieu Moy
 bzr cat now works nicely with revno:N:path too  | 
55  | 
|
56  | 
os.chdir('..')  | 
|
57  | 
||
| 
1907.4.10
by Matthieu Moy
 Cut long lines, prevent "path" component from being used in revno:branch/path.  | 
58  | 
self.assertEquals(bzr('cat', 'branch/a', '-r', 'revno:1:branch'),  | 
59  | 
'foo\n')  | 
|
| 
1907.4.3
by Matthieu Moy
 bzr cat now works nicely with revno:N:path too  | 
60  | 
bzr('cat', 'a', retcode=3)  | 
61  | 
bzr('cat', 'a', '-r', 'revno:1:branch-that-does-not-exist', retcode=3)  | 
|
62  | 
||
| 
2073.2.4
by wang
 Fix syntax error in test.  | 
63  | 
def test_cat_different_id(self):  | 
| 
2073.2.1
by wang
 ``bzr cat`` can look up contents of removed or renamed files. If the  | 
64  | 
"""'cat' works with old and new files"""  | 
| 
2073.2.4
by wang
 Fix syntax error in test.  | 
65  | 
tree = self.make_branch_and_tree('.')  | 
| 
2073.2.3
by wang
 Change option name to --name-from-revision. Always make new tree the  | 
66  | 
        # the files are named after their path in the revision and
 | 
67  | 
        # current trees later in the test case
 | 
|
68  | 
        # a-rev-tree is special because it appears in both the revision
 | 
|
69  | 
        # tree and the working tree
 | 
|
70  | 
self.build_tree_contents([('a-rev-tree', 'foo\n'),  | 
|
71  | 
('c-rev', 'baz\n'), ('d-rev', 'bar\n')])  | 
|
72  | 
tree.lock_write()  | 
|
73  | 
try:  | 
|
74  | 
tree.add(['a-rev-tree', 'c-rev', 'd-rev'])  | 
|
75  | 
tree.commit('add test files')  | 
|
76  | 
tree.remove(['d-rev'])  | 
|
77  | 
tree.rename_one('a-rev-tree', 'b-tree')  | 
|
78  | 
tree.rename_one('c-rev', 'a-rev-tree')  | 
|
79  | 
||
80  | 
            # 'b-tree' is not present in the old tree.
 | 
|
81  | 
self.run_bzr_error([], 'cat', 'b-tree', '--name-from-revision')  | 
|
82  | 
||
83  | 
            # get to the old file automatically
 | 
|
84  | 
out, err = self.run_bzr('cat', 'd-rev')  | 
|
85  | 
self.assertEqual('bar\n', out)  | 
|
86  | 
self.assertEqual('', err)  | 
|
87  | 
||
88  | 
out, err = self.run_bzr('cat', 'a-rev-tree',  | 
|
89  | 
'--name-from-revision')  | 
|
90  | 
self.assertEqual('foo\n', out)  | 
|
91  | 
self.assertEqual('', err)  | 
|
92  | 
||
93  | 
out, err = self.run_bzr('cat', 'a-rev-tree')  | 
|
94  | 
self.assertEqual('baz\n', out)  | 
|
95  | 
self.assertEqual('', err)  | 
|
96  | 
finally:  | 
|
97  | 
tree.unlock()  | 
|
98  | 
||
| 
2158.1.1
by Wouter van Heyst
 Fix #73500 mostly by catching a NotLocalUrl exception in cmd_cat.  | 
99  | 
def test_remote_cat(self):  | 
100  | 
wt = self.make_branch_and_tree('.')  | 
|
| 
2158.1.2
by Wouter van Heyst
 Actually check if cat returns the right content.  | 
101  | 
self.build_tree(['README'])  | 
| 
2158.1.1
by Wouter van Heyst
 Fix #73500 mostly by catching a NotLocalUrl exception in cmd_cat.  | 
102  | 
wt.add('README')  | 
103  | 
wt.commit('Making sure there is a basis_tree available')  | 
|
104  | 
||
105  | 
url = self.get_readonly_url() + '/README'  | 
|
| 
2158.1.2
by Wouter van Heyst
 Actually check if cat returns the right content.  | 
106  | 
out, err = self.run_bzr('cat', url)  | 
107  | 
self.assertEqual('contents of README\n', out)  |