1658.1.6
by Martin Pool
init-repo shouldn't insist on creating a new directory (Malone #38331) |
1 |
# Copyright (C) 2005, 2006 by 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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Black-box tests for repositories with shared branches"""
|
|
18 |
||
19 |
import os |
|
20 |
||
21 |
from bzrlib.tests import TestCaseInTempDir |
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
22 |
import bzrlib.bzrdir |
1658.1.6
by Martin Pool
init-repo shouldn't insist on creating a new directory (Malone #38331) |
23 |
from bzrlib.bzrdir import BzrDir |
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
24 |
import bzrlib.errors as errors |
1558.5.1
by Aaron Bentley
Added make-repository command |
25 |
|
26 |
class TestSharedRepo(TestCaseInTempDir): |
|
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
27 |
|
1558.5.4
by Aaron Bentley
Added bzr init test |
28 |
def test_make_repository(self): |
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
29 |
out, err = self.run_bzr("init-repository", "a") |
30 |
self.assertEqual(out, "") |
|
31 |
self.assertEqual(err, "") |
|
32 |
dir = bzrlib.bzrdir.BzrDir.open('a') |
|
33 |
self.assertIs(dir.open_repository().is_shared(), True) |
|
34 |
self.assertRaises(errors.NotBranchError, dir.open_branch) |
|
35 |
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree) |
|
1558.5.4
by Aaron Bentley
Added bzr init test |
36 |
|
1658.1.6
by Martin Pool
init-repo shouldn't insist on creating a new directory (Malone #38331) |
37 |
def test_init_repo_existing_dir(self): |
38 |
"""Make repo in existing directory.
|
|
39 |
|
|
40 |
(Malone #38331)
|
|
41 |
"""
|
|
42 |
out, err = self.run_bzr("init-repository", ".") |
|
43 |
dir = BzrDir.open('.') |
|
44 |
self.assertTrue(dir.open_repository()) |
|
45 |
||
1558.5.4
by Aaron Bentley
Added bzr init test |
46 |
def test_init(self): |
1558.5.6
by Aaron Bentley
Renamed make-repo init-repo |
47 |
self.run_bzr("init-repo", "a") |
1694.2.6
by Martin Pool
[merge] bzr.dev |
48 |
self.run_bzr("init", "--format=default", "a/b") |
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
49 |
dir = bzrlib.bzrdir.BzrDir.open('a') |
50 |
self.assertIs(dir.open_repository().is_shared(), True) |
|
51 |
self.assertRaises(errors.NotBranchError, dir.open_branch) |
|
52 |
self.assertRaises(errors.NoWorkingTree, dir.open_workingtree) |
|
53 |
bdir = bzrlib.bzrdir.BzrDir.open('a/b') |
|
54 |
bdir.open_branch() |
|
55 |
self.assertRaises(errors.NoRepositoryPresent, bdir.open_repository) |
|
56 |
self.assertRaises(errors.NoWorkingTree, bdir.open_workingtree) |
|
1558.5.5
by Aaron Bentley
Added tests for branch |
57 |
|
58 |
def test_branch(self): |
|
1558.5.6
by Aaron Bentley
Renamed make-repo init-repo |
59 |
self.run_bzr("init-repo", "a") |
1694.2.6
by Martin Pool
[merge] bzr.dev |
60 |
self.run_bzr("init", "--format=default", "a/b") |
1558.5.5
by Aaron Bentley
Added tests for branch |
61 |
self.run_bzr('branch', 'a/b', 'a/c') |
1558.5.9
by Aaron Bentley
Updated tests per Robert Collins' suggestions |
62 |
cdir = bzrlib.bzrdir.BzrDir.open('a/c') |
63 |
cdir.open_branch() |
|
64 |
self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository) |
|
65 |
self.assertRaises(errors.NoWorkingTree, cdir.open_workingtree) |
|
1624.2.2
by Erik Bågfors
tests for --tree |
66 |
|
67 |
def test_branch_tree(self): |
|
1624.2.4
by Erik Bågfors
rename --tree to --trees |
68 |
self.run_bzr("init-repo", "--trees", "a") |
1694.2.6
by Martin Pool
[merge] bzr.dev |
69 |
self.run_bzr("init", "--format=default", "b") |
1624.2.2
by Erik Bågfors
tests for --tree |
70 |
file('b/hello', 'wt').write('bar') |
71 |
self.run_bzr("add", "b/hello") |
|
72 |
self.run_bzr("commit", "-m", "bar", "b/hello") |
|
73 |
||
74 |
self.run_bzr('branch', 'b', 'a/c') |
|
75 |
cdir = bzrlib.bzrdir.BzrDir.open('a/c') |
|
76 |
cdir.open_branch() |
|
77 |
self.assertRaises(errors.NoRepositoryPresent, cdir.open_repository) |
|
1634.1.2
by Robert Collins
Merge Erik Bågfors --trees option for init-repository. |
78 |
self.failUnlessExists('a/c/hello') |
1624.2.3
by Erik Bågfors
better test for --tree option |
79 |
cdir.open_workingtree() |
1624.2.2
by Erik Bågfors
tests for --tree |
80 |