bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4273.1.19
by Aaron Bentley
Implement reference command |
1 |
# Copyright (C) 2009 Canonical Ltd
|
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
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
|
4273.1.21
by Aaron Bentley
Update from review |
17 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
18 |
from breezy import ( |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
19 |
controldir, |
|
4273.1.19
by Aaron Bentley
Implement reference command |
20 |
)
|
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
21 |
from breezy.bzr import ( |
22 |
branch as _mod_bzrbranch, |
|
23 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
24 |
from breezy.tests import TestCaseWithTransport |
|
4273.1.19
by Aaron Bentley
Implement reference command |
25 |
|
|
4273.1.21
by Aaron Bentley
Update from review |
26 |
|
|
4273.1.19
by Aaron Bentley
Implement reference command |
27 |
class TestReference(TestCaseWithTransport): |
28 |
||
|
6155.6.2
by Jelmer Vernooij
Simplify handling of default format. |
29 |
def get_default_format(self): |
|
7131.11.1
by Jelmer Vernooij
Use BzrBranchFormat8 in development-subtree. |
30 |
return controldir.format_registry.make_controldir('development-subtree') |
|
4273.1.19
by Aaron Bentley
Implement reference command |
31 |
|
32 |
def test_no_args_lists(self): |
|
33 |
branch = self.make_branch('branch') |
|
|
6926.2.5
by Jelmer Vernooij
Swap order for nested tree functions. |
34 |
branch.set_reference_info('path', 'http://example.org', b'file-id') |
35 |
branch.set_reference_info('lath', 'http://example.org/2', b'file-id2') |
|
|
4273.1.19
by Aaron Bentley
Implement reference command |
36 |
out, err = self.run_bzr('reference', working_dir='branch') |
37 |
lines = out.splitlines() |
|
38 |
self.assertEqual('lath http://example.org/2', lines[0]) |
|
39 |
self.assertEqual('path http://example.org', lines[1]) |
|
40 |
||
41 |
def make_tree_with_reference(self): |
|
42 |
tree = self.make_branch_and_tree('tree') |
|
43 |
self.build_tree(['tree/newpath']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
44 |
tree.add('newpath', b'file-id') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
45 |
tree.branch.set_reference_info( |
46 |
'newpath', 'http://example.org', b'file-id') |
|
|
6926.2.5
by Jelmer Vernooij
Swap order for nested tree functions. |
47 |
tree.branch.set_reference_info('lath', 'http://example.org/2', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
48 |
b'file-id2') |
|
4273.1.19
by Aaron Bentley
Implement reference command |
49 |
return tree |
50 |
||
51 |
def test_uses_working_tree_location(self): |
|
52 |
tree = self.make_tree_with_reference() |
|
53 |
out, err = self.run_bzr('reference', working_dir='tree') |
|
54 |
self.assertContainsRe(out, 'newpath http://example.org\n') |
|
55 |
||
56 |
def test_uses_basis_tree_location(self): |
|
57 |
tree = self.make_tree_with_reference() |
|
58 |
tree.commit('add newpath') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
59 |
tree.controldir.destroy_workingtree() |
|
4273.1.19
by Aaron Bentley
Implement reference command |
60 |
out, err = self.run_bzr('reference', working_dir='tree') |
61 |
self.assertContainsRe(out, 'newpath http://example.org\n') |
|
62 |
||
63 |
def test_one_arg_displays(self): |
|
64 |
tree = self.make_tree_with_reference() |
|
65 |
out, err = self.run_bzr('reference newpath', working_dir='tree') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
66 |
self.assertEqual('newpath http://example.org\n', out) |
|
4273.1.19
by Aaron Bentley
Implement reference command |
67 |
|
68 |
def test_one_arg_uses_containing_tree(self): |
|
69 |
tree = self.make_tree_with_reference() |
|
70 |
out, err = self.run_bzr('reference tree/newpath') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
71 |
self.assertEqual('newpath http://example.org\n', out) |
|
4273.1.19
by Aaron Bentley
Implement reference command |
72 |
|
73 |
def test_two_args_sets(self): |
|
74 |
tree = self.make_branch_and_tree('tree') |
|
75 |
self.build_tree(['tree/file']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
76 |
tree.add('file', b'file-id') |
|
4273.1.19
by Aaron Bentley
Implement reference command |
77 |
out, err = self.run_bzr('reference tree/file http://example.org') |
|
6926.2.5
by Jelmer Vernooij
Swap order for nested tree functions. |
78 |
location, file_id = tree.branch.get_reference_info('file') |
|
4273.1.19
by Aaron Bentley
Implement reference command |
79 |
self.assertEqual('http://example.org', location) |
|
6926.2.5
by Jelmer Vernooij
Swap order for nested tree functions. |
80 |
self.assertEqual(b'file-id', file_id) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
81 |
self.assertEqual('', out) |
82 |
self.assertEqual('', err) |
|
|
4273.1.19
by Aaron Bentley
Implement reference command |
83 |
|
84 |
def test_missing_file(self): |
|
85 |
tree = self.make_branch_and_tree('tree') |
|
86 |
out, err = self.run_bzr('reference file http://example.org', |
|
87 |
working_dir='tree', retcode=3) |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
88 |
self.assertEqual('brz: ERROR: file is not versioned.\n', err) |
|
7131.9.1
by Jelmer Vernooij
Support --force option to 'bzr reference'. |
89 |
|
90 |
def test_missing_file_forced(self): |
|
91 |
tree = self.make_branch_and_tree('tree') |
|
|
7131.9.2
by Jelmer Vernooij
s/--force/--force-unversioned/ |
92 |
out, err = self.run_bzr( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
93 |
'reference --force-unversioned file http://example.org', |
94 |
working_dir='tree') |
|
|
7131.9.1
by Jelmer Vernooij
Support --force option to 'bzr reference'. |
95 |
location, file_id = tree.branch.get_reference_info('file') |
96 |
self.assertEqual('http://example.org', location) |
|
97 |
self.assertEqual('', out) |
|
98 |
self.assertEqual('', err) |