/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_rmbranch.py

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2010 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
 
 
17
 
 
18
"""Black-box tests for brz rmbranch."""
 
19
 
 
20
from breezy import (
 
21
    controldir,
 
22
    )
 
23
from breezy.tests import (
 
24
    TestCaseWithTransport,
 
25
    )
 
26
 
 
27
 
 
28
class TestRemoveBranch(TestCaseWithTransport):
 
29
 
 
30
    def example_tree(self, path='.', format=None):
 
31
        tree = self.make_branch_and_tree(path, format=format)
 
32
        self.build_tree_contents([(path + '/hello', b'foo')])
 
33
        tree.add('hello')
 
34
        tree.commit(message='setup')
 
35
        self.build_tree_contents([(path + '/goodbye', b'baz')])
 
36
        tree.add('goodbye')
 
37
        tree.commit(message='setup')
 
38
        return tree
 
39
 
 
40
    def test_remove_local(self):
 
41
        # Remove a local branch.
 
42
        tree = self.example_tree('a')
 
43
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
 
44
                           'rmbranch a')
 
45
        self.run_bzr('rmbranch --force a')
 
46
        dir = controldir.ControlDir.open('a')
 
47
        self.assertFalse(dir.has_branch())
 
48
        self.assertPathExists('a/hello')
 
49
        self.assertPathExists('a/goodbye')
 
50
 
 
51
    def test_no_branch(self):
 
52
        # No branch in the current directory.
 
53
        self.make_repository('a')
 
54
        self.run_bzr_error(['Not a branch'], 'rmbranch a')
 
55
 
 
56
    def test_no_tree(self):
 
57
        # removing the active branch is possible if there is no tree
 
58
        tree = self.example_tree('a')
 
59
        tree.controldir.destroy_workingtree()
 
60
        self.run_bzr('rmbranch', working_dir='a')
 
61
        dir = controldir.ControlDir.open('a')
 
62
        self.assertFalse(dir.has_branch())
 
63
 
 
64
    def test_no_arg(self):
 
65
        # location argument defaults to current directory
 
66
        self.example_tree('a')
 
67
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
 
68
                           'rmbranch a')
 
69
        self.run_bzr('rmbranch --force', working_dir='a')
 
70
        dir = controldir.ControlDir.open('a')
 
71
        self.assertFalse(dir.has_branch())
 
72
 
 
73
    def test_remove_colo(self):
 
74
        # Remove a colocated branch.
 
75
        tree = self.example_tree('a')
 
76
        tree.controldir.create_branch(name="otherbranch")
 
77
        self.assertTrue(tree.controldir.has_branch('otherbranch'))
 
78
        self.run_bzr('rmbranch %s,branch=otherbranch' %
 
79
                     tree.controldir.user_url)
 
80
        dir = controldir.ControlDir.open('a')
 
81
        self.assertFalse(dir.has_branch('otherbranch'))
 
82
        self.assertTrue(dir.has_branch())
 
83
 
 
84
    def test_remove_colo_directory(self):
 
85
        # Remove a colocated branch.
 
86
        tree = self.example_tree('a')
 
87
        tree.controldir.create_branch(name="otherbranch")
 
88
        self.assertTrue(tree.controldir.has_branch('otherbranch'))
 
89
        self.run_bzr('rmbranch otherbranch -d %s' % tree.controldir.user_url)
 
90
        dir = controldir.ControlDir.open('a')
 
91
        self.assertFalse(dir.has_branch('otherbranch'))
 
92
        self.assertTrue(dir.has_branch())
 
93
 
 
94
    def test_remove_active_colo_branch(self):
 
95
        # Remove a colocated branch.
 
96
        dir = self.make_repository('a').controldir
 
97
        branch = dir.create_branch('otherbranch')
 
98
        branch.create_checkout('a')
 
99
        self.run_bzr_error(['Branch is active. Use --force to remove it.\n'],
 
100
                           'rmbranch otherbranch -d %s' % branch.controldir.user_url)
 
101
        self.assertTrue(dir.has_branch('otherbranch'))
 
102
        self.run_bzr('rmbranch --force otherbranch -d %s' %
 
103
                     branch.controldir.user_url)
 
104
        self.assertFalse(dir.has_branch('otherbranch'))
 
105