31
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
32
from bzrlib.branch import Branch
33
from bzrlib.commands import run_bzr
36
class ExternalBase(TestCaseInTempDir):
30
from bzrlib.selftest import InTempDir, BzrTestBase
33
class ExternalBase(InTempDir):
37
35
def runbzr(self, args, retcode=0,backtick=False):
38
from subprocess import call
39
except ImportError, e:
38
43
if isinstance(args, basestring):
39
44
args = args.split()
173
178
self.log(tmp_output)
174
179
self.assertEquals(output, tmp_output)
176
def example_branch(test):
178
file('hello', 'wt').write('foo')
179
test.runbzr('add hello')
180
test.runbzr('commit -m setup hello')
181
file('goodbye', 'wt').write('baz')
182
test.runbzr('add goodbye')
183
test.runbzr('commit -m setup goodbye')
185
def test_revert(self):
186
self.example_branch()
187
file('hello', 'wt').write('bar')
188
file('goodbye', 'wt').write('qux')
189
self.runbzr('revert hello')
190
self.check_file_contents('hello', 'foo')
191
self.check_file_contents('goodbye', 'qux')
192
self.runbzr('revert')
193
self.check_file_contents('goodbye', 'baz')
195
def test_merge(self):
196
from bzrlib.branch import Branch
202
self.example_branch()
204
self.runbzr('branch a b')
206
file('goodbye', 'wt').write('quux')
207
self.runbzr(['commit', '-m', "more u's are always good"])
210
file('hello', 'wt').write('quuux')
211
# We can't merge when there are in-tree changes
212
self.runbzr('merge ../b', retcode=1)
213
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
214
self.runbzr('merge ../b')
215
self.check_file_contents('goodbye', 'quux')
216
# Merging a branch pulls its revision into the tree
219
a.get_revision_xml(b.last_patch())
221
self.log('pending merges: %s', a.pending_merges())
222
# assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
223
# % (a.pending_merges(), b.last_patch())
226
def test_add_reports(self):
227
"""add command prints the names of added files."""
228
b = Branch('.', init=True)
229
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
231
from cStringIO import StringIO
234
ret = self.apply_redirected(None, out, None,
237
self.assertEquals(ret, 0)
239
# the ordering is not defined at the moment
240
results = sorted(out.getvalue().rstrip('\n').split('\n'))
241
self.assertEquals(['added dir',
247
181
class OldTests(ExternalBase):
248
"""old tests moved from ./testbzr."""
182
# old tests moved from ./testbzr
250
183
def test_bzr(self):
251
184
from os import chdir, mkdir
252
185
from os.path import exists