bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2006-2011 Canonical Ltd
|
|
1558.5.1
by Aaron Bentley
Added make-repository command |
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
|
|
1558.5.1
by Aaron Bentley
Added make-repository command |
16 |
|
17 |
"""Black-box tests for repositories with shared branches"""
|
|
18 |
||
19 |
import os |
|
20 |
||
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
21 |
from breezy.bzr.bzrdir import BzrDirMetaFormat1 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
22 |
from breezy.controldir import ControlDir |
23 |
import breezy.errors as errors |
|
24 |
from breezy.tests import TestCaseInTempDir |
|
|
6366.1.4
by Jelmer Vernooij
Test connection count calls for most blackbox commands. |
25 |
|
|
1558.5.1
by Aaron Bentley
Added make-repository command |
26 |
|
27 |
class TestSharedRepo(TestCaseInTempDir): |
|
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
28 |
|
|
1558.5.4
by Aaron Bentley
Added bzr init test |
29 |
def test_make_repository(self): |
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
30 |
out, err = self.run_bzr("init-shared-repository a") |
|
3535.9.5
by Marius Kruger
remove a trailing space I added |
31 |
self.assertEqual(out, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
32 |
"""Shared repository with trees (format: 2a) |
|
3535.9.2
by Marius Kruger
make init and init-repo tests pass again |
33 |
Location:
|
34 |
shared repository: a
|
|
35 |
""") |
|
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
36 |
self.assertEqual(err, "") |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
37 |
dir = ControlDir.open('a') |
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
38 |
self.assertIs(dir.open_repository().is_shared(), True) |
39 |
self.assertRaises(errors.NotBranchError, dir.open_branch) |
|
|
3535.9.6
by Marius Kruger
add explicit blackbox tests for 'init -q' and 'init-repo -q' |
40 |
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree) |
41 |
||
42 |
def test_make_repository_quiet(self): |
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
43 |
out, err = self.run_bzr("init-shared-repository a -q") |
|
3535.9.6
by Marius Kruger
add explicit blackbox tests for 'init -q' and 'init-repo -q' |
44 |
self.assertEqual(out, "") |
45 |
self.assertEqual(err, "") |
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
46 |
dir = ControlDir.open('a') |
|
3535.9.6
by Marius Kruger
add explicit blackbox tests for 'init -q' and 'init-repo -q' |
47 |
self.assertIs(dir.open_repository().is_shared(), True) |
48 |
self.assertRaises(errors.NotBranchError, dir.open_branch) |
|
49 |
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree) |
|
|
1558.5.4
by Aaron Bentley
Added bzr init test |
50 |
|
|
1658.1.6
by Martin Pool
init-repo shouldn't insist on creating a new directory (Malone #38331) |
51 |
def test_init_repo_existing_dir(self): |
52 |
"""Make repo in existing directory. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
53 |
|
|
1658.1.6
by Martin Pool
init-repo shouldn't insist on creating a new directory (Malone #38331) |
54 |
(Malone #38331)
|
55 |
"""
|
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
56 |
out, err = self.run_bzr("init-shared-repository .") |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
57 |
dir = ControlDir.open('.') |
|
1658.1.6
by Martin Pool
init-repo shouldn't insist on creating a new directory (Malone #38331) |
58 |
self.assertTrue(dir.open_repository()) |
59 |
||
|
1558.5.4
by Aaron Bentley
Added bzr init test |
60 |
def test_init(self): |
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
61 |
self.run_bzr("init-shared-repo a") |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
62 |
self.run_bzr("init --format=default a/b") |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
63 |
dir = ControlDir.open('a') |
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
64 |
self.assertIs(dir.open_repository().is_shared(), True) |
65 |
self.assertRaises(errors.NotBranchError, dir.open_branch) |
|
66 |
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree) |
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
67 |
bdir = ControlDir.open('a/b') |
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
68 |
bdir.open_branch() |
69 |
self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository) |
|
|
2257.2.1
by Wouter van Heyst
Change the ui level default for init-repo to --trees. |
70 |
wt = bdir.open_workingtree() |
|
1558.5.5
by Aaron Bentley
Added tests for branch |
71 |
|
72 |
def test_branch(self): |
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
73 |
self.run_bzr("init-shared-repo a") |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
74 |
self.run_bzr("init --format=default a/b") |
75 |
self.run_bzr('branch a/b a/c') |
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
76 |
cdir = ControlDir.open('a/c') |
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
77 |
cdir.open_branch() |
78 |
self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository) |
|
|
2257.2.1
by Wouter van Heyst
Change the ui level default for init-repo to --trees. |
79 |
cdir.open_workingtree() |
|
1624.2.2
by Erik Bågfors
tests for --tree |
80 |
|
81 |
def test_branch_tree(self): |
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
82 |
self.run_bzr("init-shared-repo --trees a") |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
83 |
self.run_bzr("init --format=default b") |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
84 |
with open('b/hello', 'wt') as f: |
85 |
f.write('bar') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
86 |
self.run_bzr("add b/hello") |
87 |
self.run_bzr("commit -m bar b/hello") |
|
|
1624.2.2
by Erik Bågfors
tests for --tree |
88 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
89 |
self.run_bzr('branch b a/c') |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
90 |
cdir = ControlDir.open('a/c') |
|
1624.2.2
by Erik Bågfors
tests for --tree |
91 |
cdir.open_branch() |
92 |
self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository) |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
93 |
self.assertPathExists('a/c/hello') |
|
1624.2.3
by Erik Bågfors
better test for --tree option |
94 |
cdir.open_workingtree() |
|
1624.2.2
by Erik Bågfors
tests for --tree |
95 |
|
|
2257.2.2
by Wouter van Heyst
Actually test that `bzr init-repo --{no,}-trees` still works |
96 |
def test_trees_default(self): |
97 |
# 0.15 switched to trees by default
|
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
98 |
self.run_bzr("init-shared-repo repo") |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
99 |
repo = ControlDir.open("repo").open_repository() |
|
2257.2.2
by Wouter van Heyst
Actually test that `bzr init-repo --{no,}-trees` still works |
100 |
self.assertEqual(True, repo.make_working_trees()) |
101 |
||
102 |
def test_trees_argument(self): |
|
103 |
# Supplying the --trees argument should be harmless,
|
|
104 |
# as it was previously non-default we need to get it right.
|
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
105 |
self.run_bzr("init-shared-repo --trees trees") |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
106 |
repo = ControlDir.open("trees").open_repository() |
|
2257.2.2
by Wouter van Heyst
Actually test that `bzr init-repo --{no,}-trees` still works |
107 |
self.assertEqual(True, repo.make_working_trees()) |
108 |
||
109 |
def test_no_trees_argument(self): |
|
110 |
# --no-trees should make it so that there is no working tree
|
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
111 |
self.run_bzr("init-shared-repo --no-trees notrees") |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
112 |
repo = ControlDir.open("notrees").open_repository() |
|
2257.2.2
by Wouter van Heyst
Actually test that `bzr init-repo --{no,}-trees` still works |
113 |
self.assertEqual(False, repo.make_working_trees()) |
|
4017.3.1
by Robert Collins
Add effort test for init-repo on smart server urls. |
114 |
|
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
115 |
def test_notification_on_branch_from_repository(self): |
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
116 |
out, err = self.run_bzr("init-shared-repository -q a") |
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
117 |
self.assertEqual(out, "") |
118 |
self.assertEqual(err, "") |
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
119 |
dir = ControlDir.open('a') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
120 |
dir.open_repository() # there is a repository there |
|
4734.4.4
by Brian de Alwis
Added tests to ensure branching-from-repository error returns detail |
121 |
e = self.assertRaises(errors.NotBranchError, dir.open_branch) |
|
4734.4.7
by Andrew Bennetts
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails) |
122 |
self.assertContainsRe(str(e), "location is a repository") |
|
4734.4.9
by Andrew Bennetts
More tests and comments. |
123 |
|
124 |
def test_notification_on_branch_from_nonrepository(self): |
|
125 |
fmt = BzrDirMetaFormat1() |
|
126 |
t = self.get_transport() |
|
127 |
t.mkdir('a') |
|
128 |
dir = fmt.initialize_on_transport(t.clone('a')) |
|
129 |
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository) |
|
130 |
e = self.assertRaises(errors.NotBranchError, dir.open_branch) |
|
131 |
self.assertNotContainsRe(str(e), "location is a repository") |
|
|
5107.3.6
by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts. |
132 |
|
133 |
def test_init_repo_with_post_repo_init_hook(self): |
|
134 |
calls = [] |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
135 |
ControlDir.hooks.install_named_hook( |
136 |
'post_repo_init', calls.append, None) |
|
|
5107.3.6
by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts. |
137 |
self.assertLength(0, calls) |
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
138 |
self.run_bzr("init-shared-repository a") |
|
5107.3.6
by Marco Pantaleoni
Documented behaviour of 'post_branch_init' for lightweight checkouts. |
139 |
self.assertLength(1, calls) |
|
5187.2.4
by Parth Malwankar
added tests. |
140 |
|
|
5187.2.6
by Parth Malwankar
lockdir no long mandates whoami but uses unicode version of getuser |
141 |
def test_init_repo_without_username(self): |
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
142 |
"""Ensure init-shared-repo works if username is not set. |
|
5187.2.4
by Parth Malwankar
added tests. |
143 |
"""
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
144 |
# brz makes user specified whoami mandatory for operations
|
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
145 |
# like commit as whoami is recorded. init-shared-repo however is not so
|
146 |
# final and uses whoami only in a lock file. Without whoami the login name
|
|
147 |
# is used. This test is to ensure that init-shared-repo passes even
|
|
148 |
# when whoami is not available.
|
|
|
5570.3.12
by Vincent Ladeuil
Replace osutils.set_or_unset_env calls with self.overrideEnv. |
149 |
self.overrideEnv('EMAIL', None) |
|
6622.1.28
by Jelmer Vernooij
More renames; commands in output, environment variables. |
150 |
self.overrideEnv('BRZ_EMAIL', None) |
|
7385.2.1
by Jelmer Vernooij
Rename init-repo to init-shared-repo. |
151 |
out, err = self.run_bzr(['init-shared-repo', 'foo']) |
|
5187.2.6
by Parth Malwankar
lockdir no long mandates whoami but uses unicode version of getuser |
152 |
self.assertEqual(err, '') |
153 |
self.assertTrue(os.path.exists('foo')) |