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):
318
assert os.path.exists('branch1')
319
assert not os.path.exists('branch2')
320
# Can't create a branch if it already exists
321
runbzr('branch branch1', retcode=1)
322
# Can't create a branch if its parent doesn't exist
323
runbzr('branch /unlikely/to/exist', retcode=1)
324
runbzr('branch branch1 branch2')
325
assert exists('branch2')
326
assert exists('branch2/sub1')
327
assert exists('branch2/sub1/hello.txt')
329
runbzr('branch --revision 0 branch1 branch3')
330
assert not exists('branch3/sub1/hello.txt')
331
runbzr('branch --revision 0..3 branch1 branch4', retcode=1)
335
runbzr('pull', retcode=1)
336
runbzr('pull ../branch2')
339
runbzr('commit --unchanged -m empty')
341
chdir('../../branch2')
343
runbzr('commit --unchanged -m empty')
345
runbzr('commit --unchanged -m empty')
346
runbzr('pull', retcode=1)
349
progress('status after remove')
350
mkdir('status-after-remove')
351
# see mail from William Dodé, 2005-05-25
352
# $ bzr init; touch a; bzr add a; bzr commit -m "add a"
353
# * looking for changes...
358
# bzr: local variable 'kind' referenced before assignment
359
# at /vrac/python/bazaar-ng/bzrlib/diff.py:286 in compare_trees()
360
# see ~/.bzr.log for debug information
361
chdir('status-after-remove')
363
file('a', 'w').write('foo')
365
runbzr(['commit', '-m', 'add a'])
373
progress("recursive and non-recursive add")
378
fp = os.path.join('foo', 'test.txt')
382
runbzr('add --no-recurse foo')
383
runbzr('file-id foo')
384
runbzr('file-id ' + fp, 1) # not versioned yet
385
runbzr('commit -m add-dir-only')
387
self.runbzr('file-id ' + fp, 1) # still not versioned
389
self.runbzr('add foo')
390
self.runbzr('file-id ' + fp)
391
self.runbzr('commit -m add-sub-file')
357
397
class RevertCommand(ExternalBase):
358
398
def runTest(self):
359
399
self.runbzr('init')
361
401
file('hello', 'wt').write('foo')
362
402
self.runbzr('add hello')
363
403
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
405
file('hello', 'wt').write('bar')
370
file('goodbye', 'wt').write('qux')
371
406
self.runbzr('revert hello')
372
407
self.check_file_contents('hello', 'foo')
373
self.check_file_contents('goodbye', 'qux')
374
self.runbzr('revert')
375
self.check_file_contents('goodbye', 'baz')