1
# Copyright (C) 2005 by Canonical Ltd
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.
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.
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
18
"""Tests of bound branches (binding, unbinding, commit, etc) command.
23
from cStringIO import StringIO
25
from bzrlib.selftest import TestCaseInTempDir
26
from bzrlib.branch import Branch
28
class TestBoundBranches(TestCaseInTempDir):
30
def create_branches(self):
31
self.build_tree(['base/', 'base/a', 'base/b'])
36
self.run_bzr('commit', '-m', 'init')
40
bzr('get', '--bound', 'base', 'child')
42
self.failUnlessExists('child')
46
self.failUnlessExists('.bzr/bound')
49
def check_revno(self, val):
50
self.assertEquals(self.capture('bzr revno').strip(), val)
52
def test_bound_commit(self):
54
self.create_branches()
57
open('a', 'wb').write('new contents\n')
58
bzr('commit', '-m', 'child')
62
# Make sure it committed on the parent
66
def test_bound_fail(self)
67
"""Make sure commit fails if out of date."""
69
self.create_branches()
72
open('a', 'wb').write('new base contents\n')
73
bzr('commit', '-m', 'base')
76
open('b', 'wb').write('new b child contents\n')
77
bzr('commit', '-m', 'child', retcode=1)
82
bzr('commit', '-m', 'child')
87
def test_unbinding(self):
89
self.create_branches()
92
open('a', 'wb').write('new base contents\n')
93
bzr('commit', '-m', 'base')
97
open('b', 'wb').write('new b child contents\n')
99
bzr('commit', '-m', 'child', retcode=1)
100
self.check_revno('1')
102
bzr('commit', '-m', 'child')
103
self.check_revno('2')
105
bzr('bind', retcode=1)