26
26
it's normally invoked.
29
# this code was previously in testbzr
31
from bzrlib.selftest import TestBase, InTempDir, BzrTestBase
31
from unittest import TestCase
32
from bzrlib.selftest import TestBase, InTempDir
52
class MvCommand(BzrTestBase):
54
"""Test two modes of operation for mv"""
55
b = Branch('.', init=True)
56
self.build_tree(['a', 'c', 'subdir/'])
57
self.run_bzr('mv', 'a', 'b')
58
self.run_bzr('mv', 'b', 'subdir')
59
self.run_bzr('mv', 'subdir/b', 'a')
60
self.run_bzr('mv', 'a', 'b', 'subdir')
61
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
65
class TestVersion(BzrTestBase):
66
"""Check output from version command and master option is reasonable"""
53
class TestVersion(ExternalBase):
68
55
# output is intentionally passed through to stdout so that we
69
56
# can see the version being tested
70
from cStringIO import StringIO
73
sys.stdout = tmp_out = StringIO()
75
self.run_bzr('version')
79
output = tmp_out.getvalue()
80
self.log('bzr version output:')
83
self.assert_(output.startswith('bzr (bazaar-ng) '))
84
self.assertNotEqual(output.index('Canonical'), -1)
86
# make sure --version is consistent
88
sys.stdout = tmp_out = StringIO()
90
self.run_bzr('--version')
94
self.log('bzr --version output:')
95
self.log(tmp_out.getvalue())
97
self.assertEquals(output, tmp_out.getvalue())
57
self.runbzr(['version'])
103
61
class HelpCommands(ExternalBase):
330
runbzr('log -v --forward')
331
runbzr('log -m', retcode=1)
332
log_out = backtick('bzr log -m commit')
333
assert "this is my new commit" in log_out
334
assert "rename nested" not in log_out
335
assert 'revision-id' not in log_out
336
assert 'revision-id' in backtick('bzr log --show-ids -m commit')
339
291
progress("file with spaces in name")
312
assert os.path.exists('branch1')
313
assert not os.path.exists('branch2')
314
# Can't create a branch if it already exists
315
runbzr('branch branch1', retcode=1)
316
# Can't create a branch if its parent doesn't exist
317
runbzr('branch /unlikely/to/exist', retcode=1)
318
runbzr('branch branch1 branch2')
322
runbzr('pull', retcode=1)
323
runbzr('pull ../branch2')
326
runbzr('commit --unchanged -m empty')
328
chdir('../../branch2')
330
runbzr('commit --unchanged -m empty')
332
runbzr('commit --unchanged -m empty')
333
runbzr('pull', retcode=1)
336
progress('status after remove')
337
mkdir('status-after-remove')
338
# see mail from William Dodé, 2005-05-25
339
# $ bzr init; touch a; bzr add a; bzr commit -m "add a"
340
# * looking for changes...
345
# bzr: local variable 'kind' referenced before assignment
346
# at /vrac/python/bazaar-ng/bzrlib/diff.py:286 in compare_trees()
347
# see ~/.bzr.log for debug information
348
chdir('status-after-remove')
350
file('a', 'w').write('foo')
352
runbzr(['commit', '-m', 'add a'])
360
progress("recursive and non-recursive add")
365
fp = os.path.join('foo', 'test.txt')
369
runbzr('add --no-recurse foo')
370
runbzr('file-id foo')
371
runbzr('file-id ' + fp, 1) # not versioned yet
372
runbzr('commit -m add-dir-only')
374
self.runbzr('file-id ' + fp, 1) # still not versioned
376
self.runbzr('add foo')
377
self.runbzr('file-id ' + fp)
378
self.runbzr('commit -m add-sub-file')
357
384
class RevertCommand(ExternalBase):
358
385
def runTest(self):
359
386
self.runbzr('init')
361
388
file('hello', 'wt').write('foo')
362
389
self.runbzr('add hello')
363
390
self.runbzr('commit -m setup hello')
365
file('goodbye', 'wt').write('baz')
366
self.runbzr('add goodbye')
367
self.runbzr('commit -m setup goodbye')
369
392
file('hello', 'wt').write('bar')
370
file('goodbye', 'wt').write('qux')
371
393
self.runbzr('revert hello')
372
394
self.check_file_contents('hello', 'foo')
373
self.check_file_contents('goodbye', 'qux')
374
self.runbzr('revert')
375
self.check_file_contents('goodbye', 'baz')