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): |
|
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
29 |
tree = self.make_branch_and_tree('branch') |
30 |
self.build_tree_contents([('branch/a', 'foo\n')]) |
|
31 |
tree.add('a') |
|
|
1907.4.3
by Matthieu Moy
bzr cat now works nicely with revno:N:path too |
32 |
os.chdir('branch') |
|
1185.50.9
by John Arbash Meinel
[bug 3632] Matthieu Moy- bzr cat should default to last revision |
33 |
# 'bzr cat' without an option should cat the last revision
|
|
2738.4.7
by Martin Pool
Fix up calls to run_bzr from test_cat |
34 |
self.run_bzr(['cat', 'a'], retcode=3) |
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
35 |
|
36 |
tree.commit(message='1') |
|
37 |
self.build_tree_contents([('a', 'baz\n')]) |
|
38 |
||
|
2738.4.3
by Daniel Watkins
Converted run_bzr to run_bzr_subprocess where appropriate in cat. |
39 |
# We use run_bzr_subprocess rather than run_bzr here so that we can
|
40 |
# test mangling of line-endings on Windows.
|
|
|
2738.4.7
by Martin Pool
Fix up calls to run_bzr from test_cat |
41 |
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'foo\n') |
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
42 |
|
43 |
tree.commit(message='2') |
|
|
2738.4.7
by Martin Pool
Fix up calls to run_bzr from test_cat |
44 |
self.assertEquals(self.run_bzr_subprocess(['cat', 'a'])[0], 'baz\n') |
45 |
self.assertEquals(self.run_bzr_subprocess( |
|
46 |
['cat', 'a', '-r', '1'])[0], |
|
47 |
'foo\n') |
|
48 |
self.assertEquals(self.run_bzr_subprocess( |
|
49 |
['cat', 'a', '-r', '-1'])[0], |
|
50 |
'baz\n') |
|
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
51 |
|
|
2738.4.1
by Daniel Watkins
Merged original changes and tweaked cat. |
52 |
rev_id = tree.branch.last_revision() |
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
53 |
|
|
2738.4.7
by Martin Pool
Fix up calls to run_bzr from test_cat |
54 |
self.assertEquals(self.run_bzr_subprocess( |
55 |
['cat', 'a', '-r', 'revid:%s' % rev_id])[0], |
|
56 |
'baz\n') |
|
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
57 |
|
|
1907.4.3
by Matthieu Moy
bzr cat now works nicely with revno:N:path too |
58 |
os.chdir('..') |
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
59 |
|
|
2738.4.7
by Martin Pool
Fix up calls to run_bzr from test_cat |
60 |
self.assertEquals(self.run_bzr_subprocess( |
61 |
['cat', 'branch/a', '-r', 'revno:1:branch'])[0], |
|
62 |
'foo\n') |
|
63 |
self.run_bzr(['cat', 'a'], retcode=3) |
|
64 |
self.run_bzr( |
|
65 |
['cat', 'a', '-r', 'revno:1:branch-that-does-not-exist'], |
|
66 |
retcode=3) |
|
|
2664.13.1
by Daniel Watkins
tests.blackbox.test_cat now uses internals where appropriate. |
67 |
|
|
2073.2.4
by wang
Fix syntax error in test. |
68 |
def test_cat_different_id(self): |
|
2073.2.1
by wang
``bzr cat`` can look up contents of removed or renamed files. If the |
69 |
"""'cat' works with old and new files""" |
|
2073.2.4
by wang
Fix syntax error in test. |
70 |
tree = self.make_branch_and_tree('.') |
|
2073.2.3
by wang
Change option name to --name-from-revision. Always make new tree the |
71 |
# the files are named after their path in the revision and
|
72 |
# current trees later in the test case
|
|
73 |
# a-rev-tree is special because it appears in both the revision
|
|
74 |
# tree and the working tree
|
|
75 |
self.build_tree_contents([('a-rev-tree', 'foo\n'), |
|
76 |
('c-rev', 'baz\n'), ('d-rev', 'bar\n')]) |
|
77 |
tree.lock_write() |
|
78 |
try: |
|
79 |
tree.add(['a-rev-tree', 'c-rev', 'd-rev']) |
|
80 |
tree.commit('add test files') |
|
|
2255.7.70
by Robert Collins
Workaround WorkingTree4 not having a native remove() in test_cat. |
81 |
# remove currently uses self._write_inventory -
|
82 |
# work around that for now.
|
|
83 |
tree.flush() |
|
|
2073.2.3
by wang
Change option name to --name-from-revision. Always make new tree the |
84 |
tree.remove(['d-rev']) |
85 |
tree.rename_one('a-rev-tree', 'b-tree') |
|
86 |
tree.rename_one('c-rev', 'a-rev-tree') |
|
87 |
finally: |
|
|
2379.6.1
by Alexander Belchenko
blackbox: test_cat_different_id: calling bzr as another process require free lock on win32 |
88 |
# calling bzr as another process require free lock on win32
|
|
2073.2.3
by wang
Change option name to --name-from-revision. Always make new tree the |
89 |
tree.unlock() |
90 |
||
|
2379.6.1
by Alexander Belchenko
blackbox: test_cat_different_id: calling bzr as another process require free lock on win32 |
91 |
# 'b-tree' is not present in the old tree.
|
92 |
self.run_bzr_error(["^bzr: ERROR: u?'b-tree' " |
|
93 |
"is not present in revision .+$"], |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
94 |
'cat b-tree --name-from-revision') |
|
2379.6.1
by Alexander Belchenko
blackbox: test_cat_different_id: calling bzr as another process require free lock on win32 |
95 |
|
96 |
# get to the old file automatically
|
|
|
2738.4.3
by Daniel Watkins
Converted run_bzr to run_bzr_subprocess where appropriate in cat. |
97 |
out, err = self.run_bzr_subprocess('cat d-rev') |
|
2379.6.1
by Alexander Belchenko
blackbox: test_cat_different_id: calling bzr as another process require free lock on win32 |
98 |
self.assertEqual('bar\n', out) |
99 |
self.assertEqual('', err) |
|
100 |
||
|
2738.4.6
by Daniel Watkins
Rewrapped lines longer than 79 characters. |
101 |
out, err = \ |
102 |
self.run_bzr_subprocess('cat a-rev-tree --name-from-revision') |
|
|
2379.6.1
by Alexander Belchenko
blackbox: test_cat_different_id: calling bzr as another process require free lock on win32 |
103 |
self.assertEqual('foo\n', out) |
104 |
self.assertEqual('', err) |
|
105 |
||
|
2738.4.3
by Daniel Watkins
Converted run_bzr to run_bzr_subprocess where appropriate in cat. |
106 |
out, err = self.run_bzr_subprocess('cat a-rev-tree') |
|
2379.6.1
by Alexander Belchenko
blackbox: test_cat_different_id: calling bzr as another process require free lock on win32 |
107 |
self.assertEqual('baz\n', out) |
108 |
self.assertEqual('', err) |
|
109 |
||
|
2158.1.1
by Wouter van Heyst
Fix #73500 mostly by catching a NotLocalUrl exception in cmd_cat. |
110 |
def test_remote_cat(self): |
111 |
wt = self.make_branch_and_tree('.') |
|
|
2158.1.2
by Wouter van Heyst
Actually check if cat returns the right content. |
112 |
self.build_tree(['README']) |
|
2158.1.1
by Wouter van Heyst
Fix #73500 mostly by catching a NotLocalUrl exception in cmd_cat. |
113 |
wt.add('README') |
114 |
wt.commit('Making sure there is a basis_tree available') |
|
115 |
||
116 |
url = self.get_readonly_url() + '/README' |
|
|
2738.4.3
by Daniel Watkins
Converted run_bzr to run_bzr_subprocess where appropriate in cat. |
117 |
out, err = self.run_bzr_subprocess(['cat', url]) |
|
2158.1.2
by Wouter van Heyst
Actually check if cat returns the right content. |
118 |
self.assertEqual('contents of README\n', out) |
|
2309.1.1
by James Westby
Allow bzr cat to be used against treeless repositories. |
119 |
|
120 |
def test_cat_no_working_tree(self): |
|
121 |
wt = self.make_branch_and_tree('.') |
|
122 |
self.build_tree(['README']) |
|
123 |
wt.add('README') |
|
124 |
wt.commit('Making sure there is a basis_tree available') |
|
125 |
wt.branch.bzrdir.destroy_workingtree() |
|
126 |
||
127 |
url = self.get_readonly_url() + '/README' |
|
|
2738.4.3
by Daniel Watkins
Converted run_bzr to run_bzr_subprocess where appropriate in cat. |
128 |
out, err = self.run_bzr_subprocess(['cat', url]) |
|
2309.1.1
by James Westby
Allow bzr cat to be used against treeless repositories. |
129 |
self.assertEqual('contents of README\n', out) |
|
2738.4.6
by Daniel Watkins
Rewrapped lines longer than 79 characters. |
130 |