15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
# Mr. Smoketoomuch: I'm sorry?
19
# Mr. Bounder: You'd better cut down a little then.
20
# Mr. Smoketoomuch: Oh, I see! Smoke too much so I'd better cut down a little
23
19
"""Black-box tests for bzr.
25
21
These check that it behaves properly when it's invoked through the regular
26
command-line interface. This doesn't actually run a new interpreter but
27
rather starts again from the run_bzr function.
22
command-line interface.
24
This always reinvokes bzr through a new Python interpreter, which is a
25
bit inefficient but arguably tests in a way more representative of how
26
it's normally invoked.
31
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
32
# Note: Please don't add new tests here, it's too big and bulky. Instead add
33
# them into small suites in bzrlib.tests.blackbox.test_FOO for the particular
34
# UI command/aspect that is being tested.
37
from cStringIO import StringIO
43
from bzrlib.branch import Branch
44
from bzrlib.clone import copy_branch
45
from bzrlib.errors import BzrCommandError
46
from bzrlib.osutils import has_symlinks, pathjoin
47
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
48
from bzrlib.tests.blackbox import ExternalBase
50
class TestCommands(ExternalBase):
52
def test_help_commands(self):
55
self.runbzr('help commands')
56
self.runbzr('help help')
57
self.runbzr('commit -h')
59
def test_init_branch(self):
62
# Can it handle subdirectories as well?
63
self.runbzr('init subdir1')
64
self.assert_(os.path.exists('subdir1'))
65
self.assert_(os.path.exists('subdir1/.bzr'))
67
self.runbzr('init subdir2/nothere', retcode=3)
70
self.runbzr('init subdir2')
71
self.runbzr('init subdir2', retcode=3)
73
self.runbzr('init subdir2/subsubdir1')
74
self.assert_(os.path.exists('subdir2/subsubdir1/.bzr'))
76
def test_whoami(self):
77
# this should always identify something, if only "john@localhost"
79
self.runbzr("whoami --email")
81
self.assertEquals(self.runbzr("whoami --email",
82
backtick=True).count('@'), 1)
84
def test_whoami_branch(self):
85
"""branch specific user identity works."""
87
f = file('.bzr/email', 'wt')
88
f.write('Branch Identity <branch@identi.ty>')
90
bzr_email = os.environ.get('BZREMAIL')
91
if bzr_email is not None:
92
del os.environ['BZREMAIL']
93
whoami = self.runbzr("whoami",backtick=True)
94
whoami_email = self.runbzr("whoami --email",backtick=True)
95
self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
96
self.assertTrue(whoami_email.startswith('branch@identi.ty'))
97
# Verify that the environment variable overrides the value
99
os.environ['BZREMAIL'] = 'Different ID <other@environ.ment>'
100
whoami = self.runbzr("whoami",backtick=True)
101
whoami_email = self.runbzr("whoami --email",backtick=True)
102
self.assertTrue(whoami.startswith('Different ID <other@environ.ment>'))
103
self.assertTrue(whoami_email.startswith('other@environ.ment'))
104
if bzr_email is not None:
105
os.environ['BZREMAIL'] = bzr_email
107
def test_nick_command(self):
108
"""bzr nick for viewing, setting nicknames"""
112
nick = self.runbzr("nick",backtick=True)
113
self.assertEqual(nick, 'me.dev\n')
114
nick = self.runbzr("nick moo")
115
nick = self.runbzr("nick",backtick=True)
116
self.assertEqual(nick, 'moo\n')
119
def test_invalid_commands(self):
120
self.runbzr("pants", retcode=3)
121
self.runbzr("--pants off", retcode=3)
122
self.runbzr("diff --message foo", retcode=3)
124
def test_empty_commit(self):
126
self.build_tree(['hello.txt'])
127
self.runbzr("commit -m empty", retcode=3)
128
self.runbzr("add hello.txt")
129
self.runbzr("commit -m added")
131
def test_empty_commit_message(self):
133
file('foo.c', 'wt').write('int main() {}')
134
self.runbzr(['add', 'foo.c'])
135
self.runbzr(["commit", "-m", ""] , retcode=3)
137
def test_remove_deleted(self):
139
self.build_tree(['a'])
140
self.runbzr(['add', 'a'])
141
self.runbzr(['commit', '-m', 'added a'])
143
self.runbzr(['remove', 'a'])
145
def test_other_branch_commit(self):
146
# this branch is to ensure consistent behaviour, whether we're run
147
# inside a branch, or not.
148
os.mkdir('empty_branch')
149
os.chdir('empty_branch')
154
file('foo.c', 'wt').write('int main() {}')
155
file('bar.c', 'wt').write('int main() {}')
157
self.runbzr(['add', 'branch/foo.c'])
158
self.runbzr(['add', 'branch'])
159
# can't commit files in different trees; sane error
160
self.runbzr('commit -m newstuff branch/foo.c .', retcode=3)
161
self.runbzr('commit -m newstuff branch/foo.c')
162
self.runbzr('commit -m newstuff branch')
163
self.runbzr('commit -m newstuff branch', retcode=3)
165
def test_ignore_patterns(self):
166
from bzrlib.branch import Branch
167
Branch.initialize('.')
168
self.assertEquals(self.capture('unknowns'), '')
170
file('foo.tmp', 'wt').write('tmp files are ignored')
171
self.assertEquals(self.capture('unknowns'), '')
173
file('foo.c', 'wt').write('int main() {}')
174
self.assertEquals(self.capture('unknowns'), 'foo.c\n')
176
self.runbzr(['add', 'foo.c'])
177
self.assertEquals(self.capture('unknowns'), '')
179
# 'ignore' works when creating the .bzignore file
180
file('foo.blah', 'wt').write('blah')
181
self.assertEquals(self.capture('unknowns'), 'foo.blah\n')
182
self.runbzr('ignore *.blah')
183
self.assertEquals(self.capture('unknowns'), '')
184
self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\n')
186
# 'ignore' works when then .bzrignore file already exists
187
file('garh', 'wt').write('garh')
188
self.assertEquals(self.capture('unknowns'), 'garh\n')
189
self.runbzr('ignore garh')
190
self.assertEquals(self.capture('unknowns'), '')
191
self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\ngarh\n')
193
def test_revert(self):
196
file('hello', 'wt').write('foo')
197
self.runbzr('add hello')
198
self.runbzr('commit -m setup hello')
200
file('goodbye', 'wt').write('baz')
201
self.runbzr('add goodbye')
202
self.runbzr('commit -m setup goodbye')
204
file('hello', 'wt').write('bar')
205
file('goodbye', 'wt').write('qux')
206
self.runbzr('revert hello')
207
self.check_file_contents('hello', 'foo')
208
self.check_file_contents('goodbye', 'qux')
209
self.runbzr('revert')
210
self.check_file_contents('goodbye', 'baz')
212
os.mkdir('revertdir')
213
self.runbzr('add revertdir')
214
self.runbzr('commit -m f')
215
os.rmdir('revertdir')
216
self.runbzr('revert')
219
os.symlink('/unlikely/to/exist', 'symlink')
220
self.runbzr('add symlink')
221
self.runbzr('commit -m f')
223
self.runbzr('revert')
224
self.failUnlessExists('symlink')
226
os.symlink('a-different-path', 'symlink')
227
self.runbzr('revert')
228
self.assertEqual('/unlikely/to/exist',
229
os.readlink('symlink'))
231
self.log("skipping revert symlink tests")
233
file('hello', 'wt').write('xyz')
234
self.runbzr('commit -m xyz hello')
235
self.runbzr('revert -r 1 hello')
236
self.check_file_contents('hello', 'foo')
237
self.runbzr('revert hello')
238
self.check_file_contents('hello', 'xyz')
239
os.chdir('revertdir')
240
self.runbzr('revert')
243
def test_status(self):
245
self.build_tree(['hello.txt'])
246
result = self.runbzr("status")
247
self.assert_("unknown:\n hello.txt\n" in result, result)
248
self.runbzr("add hello.txt")
249
result = self.runbzr("status")
250
self.assert_("added:\n hello.txt\n" in result, result)
251
self.runbzr("commit -m added")
252
result = self.runbzr("status -r 0..1")
253
self.assert_("added:\n hello.txt\n" in result, result)
254
self.build_tree(['world.txt'])
255
result = self.runbzr("status -r 0")
256
self.assert_("added:\n hello.txt\n" \
257
"unknown:\n world.txt\n" in result, result)
259
def test_mv_modes(self):
260
"""Test two modes of operation for mv"""
261
from bzrlib.branch import Branch
262
b = Branch.initialize('.')
263
self.build_tree(['a', 'c', 'subdir/'])
264
self.run_bzr_captured(['add', self.test_dir])
265
self.run_bzr_captured(['mv', 'a', 'b'])
266
self.run_bzr_captured(['mv', 'b', 'subdir'])
267
self.run_bzr_captured(['mv', 'subdir/b', 'a'])
268
self.run_bzr_captured(['mv', 'a', 'c', 'subdir'])
269
self.run_bzr_captured(['mv', 'subdir/a', 'subdir/newa'])
271
def test_main_version(self):
272
"""Check output from version command and master option is reasonable"""
29
# this code was previously in testbzr
31
from unittest import TestCase
32
from bzrlib.selftest import TestBase, InTempDir
34
class TestVersion(TestBase):
273
36
# output is intentionally passed through to stdout so that we
274
37
# can see the version being tested
275
output = self.runbzr('version', backtick=1)
276
self.log('bzr version output:')
278
self.assert_(output.startswith('bzr (bazaar-ng) '))
279
self.assertNotEqual(output.index('Canonical'), -1)
280
# make sure --version is consistent
281
tmp_output = self.runbzr('--version', backtick=1)
282
self.log('bzr --version output:')
284
self.assertEquals(output, tmp_output)
286
def example_branch(test):
288
file('hello', 'wt').write('foo')
289
test.runbzr('add hello')
290
test.runbzr('commit -m setup hello')
291
file('goodbye', 'wt').write('baz')
292
test.runbzr('add goodbye')
293
test.runbzr('commit -m setup goodbye')
295
def test_export(self):
298
self.example_branch()
299
self.runbzr('export ../latest')
300
self.assertEqual(file('../latest/goodbye', 'rt').read(), 'baz')
301
self.runbzr('export ../first -r 1')
302
self.assert_(not os.path.exists('../first/goodbye'))
303
self.assertEqual(file('../first/hello', 'rt').read(), 'foo')
304
self.runbzr('export ../first.gz -r 1')
305
self.assertEqual(file('../first.gz/hello', 'rt').read(), 'foo')
306
self.runbzr('export ../first.bz2 -r 1')
307
self.assertEqual(file('../first.bz2/hello', 'rt').read(), 'foo')
309
from tarfile import TarFile
310
self.runbzr('export ../first.tar -r 1')
311
self.assert_(os.path.isfile('../first.tar'))
312
tf = TarFile('../first.tar')
313
self.assert_('first/hello' in tf.getnames(), tf.getnames())
314
self.assertEqual(tf.extractfile('first/hello').read(), 'foo')
315
self.runbzr('export ../first.tar.gz -r 1')
316
self.assert_(os.path.isfile('../first.tar.gz'))
317
self.runbzr('export ../first.tbz2 -r 1')
318
self.assert_(os.path.isfile('../first.tbz2'))
319
self.runbzr('export ../first.tar.bz2 -r 1')
320
self.assert_(os.path.isfile('../first.tar.bz2'))
321
self.runbzr('export ../first.tar.tbz2 -r 1')
322
self.assert_(os.path.isfile('../first.tar.tbz2'))
324
from bz2 import BZ2File
325
tf = TarFile('../first.tar.tbz2',
326
fileobj=BZ2File('../first.tar.tbz2', 'r'))
327
self.assert_('first.tar/hello' in tf.getnames(), tf.getnames())
328
self.assertEqual(tf.extractfile('first.tar/hello').read(), 'foo')
329
self.runbzr('export ../first2.tar -r 1 --root pizza')
330
tf = TarFile('../first2.tar')
331
self.assert_('pizza/hello' in tf.getnames(), tf.getnames())
333
from zipfile import ZipFile
334
self.runbzr('export ../first.zip -r 1')
335
self.failUnlessExists('../first.zip')
336
zf = ZipFile('../first.zip')
337
self.assert_('first/hello' in zf.namelist(), zf.namelist())
338
self.assertEqual(zf.read('first/hello'), 'foo')
340
self.runbzr('export ../first2.zip -r 1 --root pizza')
341
zf = ZipFile('../first2.zip')
342
self.assert_('pizza/hello' in zf.namelist(), zf.namelist())
344
self.runbzr('export ../first-zip --format=zip -r 1')
345
zf = ZipFile('../first-zip')
346
self.assert_('first-zip/hello' in zf.namelist(), zf.namelist())
349
self.example_branch()
350
file('hello', 'wt').write('hello world!')
351
self.runbzr('commit -m fixing hello')
352
output = self.runbzr('diff -r 2..3', backtick=1, retcode=1)
353
self.assert_('\n+hello world!' in output)
354
output = self.runbzr('diff -r last:3..last:1', backtick=1, retcode=1)
355
self.assert_('\n+baz' in output)
356
file('moo', 'wb').write('moo')
357
self.runbzr('add moo')
361
def test_diff_branches(self):
362
self.build_tree(['branch1/', 'branch1/file', 'branch2/'], line_endings='binary')
363
branch = Branch.initialize('branch1')
364
branch.working_tree().add(['file'])
365
branch.working_tree().commit('add file')
366
copy_branch(branch, 'branch2')
367
print >> open('branch2/file', 'wb'), 'new content'
368
branch2 = Branch.open('branch2')
369
branch2.working_tree().commit('update file')
370
# should open branch1 and diff against branch2,
371
output = self.run_bzr_captured(['diff', '-r', 'branch:branch2',
374
self.assertEquals(("=== modified file 'file'\n"
379
"+contents of branch1/file\n"
381
output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
383
self.assertEqualDiff(("=== modified file 'file'\n"
388
"+contents of branch1/file\n"
392
def test_branch(self):
393
"""Branch from one branch to another."""
396
self.example_branch()
398
self.runbzr('branch a b')
399
self.assertFileEqual('b\n', 'b/.bzr/branch-name')
400
self.runbzr('branch a c -r 1')
402
self.runbzr('commit -m foo --unchanged')
404
# naughty - abstraction violations RBC 20050928
405
print "test_branch used to delete the stores, how is this meant to work ?"
406
#shutil.rmtree('a/.bzr/revision-store')
407
#shutil.rmtree('a/.bzr/inventory-store', ignore_errors=True)
408
#shutil.rmtree('a/.bzr/text-store', ignore_errors=True)
409
self.runbzr('branch a d --basis b')
411
def test_merge(self):
412
from bzrlib.branch import Branch
416
self.example_branch()
418
self.runbzr('branch a b')
420
file('goodbye', 'wt').write('quux')
421
self.runbzr(['commit', '-m', "more u's are always good"])
424
file('hello', 'wt').write('quuux')
425
# We can't merge when there are in-tree changes
426
self.runbzr('merge ../b', retcode=3)
427
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
428
self.runbzr('merge ../b -r last:1..last:1 --merge-type blooof',
430
self.runbzr('merge ../b -r last:1..last:1 --merge-type merge3')
431
self.runbzr('revert --no-backup')
432
self.runbzr('merge ../b -r last:1..last:1 --merge-type weave')
433
self.runbzr('revert --no-backup')
434
self.runbzr('merge ../b -r last:1..last:1 --reprocess')
435
self.runbzr('revert --no-backup')
436
self.runbzr('merge ../b -r last:1')
437
self.check_file_contents('goodbye', 'quux')
438
# Merging a branch pulls its revision into the tree
440
b = Branch.open('../b')
441
a.get_revision_xml(b.last_revision())
442
self.log('pending merges: %s', a.working_tree().pending_merges())
443
self.assertEquals(a.working_tree().pending_merges(),
445
self.runbzr('commit -m merged')
446
self.runbzr('merge ../b -r last:1')
447
self.assertEqual(Branch.open('.').working_tree().pending_merges(), [])
449
def test_merge_with_missing_file(self):
450
"""Merge handles missing file conflicts"""
454
print >> file('sub/a.txt', 'wb'), "hello"
455
print >> file('b.txt', 'wb'), "hello"
456
print >> file('sub/c.txt', 'wb'), "hello"
459
self.runbzr(('commit', '-m', 'added a'))
460
self.runbzr('branch . ../b')
461
print >> file('sub/a.txt', 'ab'), "there"
462
print >> file('b.txt', 'ab'), "there"
463
print >> file('sub/c.txt', 'ab'), "there"
464
self.runbzr(('commit', '-m', 'Added there'))
465
os.unlink('sub/a.txt')
466
os.unlink('sub/c.txt')
469
self.runbzr(('commit', '-m', 'Removed a.txt'))
471
print >> file('sub/a.txt', 'ab'), "something"
472
print >> file('b.txt', 'ab'), "something"
473
print >> file('sub/c.txt', 'ab'), "something"
474
self.runbzr(('commit', '-m', 'Modified a.txt'))
475
self.runbzr('merge ../a/', retcode=1)
476
self.assert_(os.path.exists('sub/a.txt.THIS'))
477
self.assert_(os.path.exists('sub/a.txt.BASE'))
479
self.runbzr('merge ../b/', retcode=1)
480
self.assert_(os.path.exists('sub/a.txt.OTHER'))
481
self.assert_(os.path.exists('sub/a.txt.BASE'))
483
def test_inventory(self):
485
def output_equals(value, *args):
486
out = self.runbzr(['inventory'] + list(args), backtick=True)
487
self.assertEquals(out, value)
490
open('a', 'wb').write('hello\n')
496
output_equals('a\n', '--kind', 'file')
497
output_equals('b\n', '--kind', 'directory')
500
"""Test the abilities of 'bzr ls'"""
502
def bzrout(*args, **kwargs):
503
kwargs['backtick'] = True
504
return self.runbzr(*args, **kwargs)
506
def ls_equals(value, *args):
507
out = self.runbzr(['ls'] + list(args), backtick=True)
508
self.assertEquals(out, value)
511
open('a', 'wb').write('hello\n')
514
bzr('ls --verbose --null', retcode=3)
517
ls_equals('? a\n', '--verbose')
518
ls_equals('a\n', '--unknown')
519
ls_equals('', '--ignored')
520
ls_equals('', '--versioned')
521
ls_equals('a\n', '--unknown', '--ignored', '--versioned')
522
ls_equals('', '--ignored', '--versioned')
523
ls_equals('a\0', '--null')
526
ls_equals('V a\n', '--verbose')
533
open('subdir/b', 'wb').write('b\n')
539
bzr('commit -m subdir')
547
, '--verbose', '--non-recursive')
549
# Check what happens in a sub-directory
561
, '--from-root', '--null')
564
, '--from-root', '--non-recursive')
568
# Check what happens when we supply a specific revision
569
ls_equals('a\n', '--revision', '1')
571
, '--verbose', '--revision', '1')
574
ls_equals('', '--revision', '1')
576
# Now try to do ignored files.
578
open('blah.py', 'wb').write('unknown\n')
579
open('blah.pyo', 'wb').write('ignored\n')
591
ls_equals('blah.pyo\n'
593
ls_equals('blah.py\n'
600
def test_pull_verbose(self):
601
"""Pull changes from one branch to another and watch the output."""
607
self.example_branch()
612
open('b', 'wb').write('else\n')
614
bzr(['commit', '-m', 'added b'])
617
out = bzr('pull --verbose ../b', backtick=True)
618
self.failIfEqual(out.find('Added Revisions:'), -1)
619
self.failIfEqual(out.find('message:\n added b'), -1)
620
self.failIfEqual(out.find('added b'), -1)
622
# Check that --overwrite --verbose prints out the removed entries
623
bzr('commit -m foo --unchanged')
625
bzr('commit -m baz --unchanged')
626
bzr('pull ../a', retcode=3)
627
out = bzr('pull --overwrite --verbose ../a', backtick=1)
629
remove_loc = out.find('Removed Revisions:')
630
self.failIfEqual(remove_loc, -1)
631
added_loc = out.find('Added Revisions:')
632
self.failIfEqual(added_loc, -1)
634
removed_message = out.find('message:\n baz')
635
self.failIfEqual(removed_message, -1)
636
self.failUnless(remove_loc < removed_message < added_loc)
638
added_message = out.find('message:\n foo')
639
self.failIfEqual(added_message, -1)
640
self.failUnless(added_loc < added_message)
642
def test_locations(self):
643
"""Using and remembering different locations"""
647
self.runbzr('commit -m unchanged --unchanged')
648
self.runbzr('pull', retcode=3)
649
self.runbzr('merge', retcode=3)
650
self.runbzr('branch . ../b')
653
self.runbzr('branch . ../c')
654
self.runbzr('pull ../c')
657
self.runbzr('pull ../b')
659
self.runbzr('pull ../c')
660
self.runbzr('branch ../c ../d')
661
shutil.rmtree('../c')
666
self.runbzr('pull', retcode=3)
667
self.runbzr('pull ../a --remember')
670
def test_add_reports(self):
671
"""add command prints the names of added files."""
672
b = Branch.initialize('.')
673
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
674
out = self.run_bzr_captured(['add'], retcode=0)[0]
675
# the ordering is not defined at the moment
676
results = sorted(out.rstrip('\n').split('\n'))
677
self.assertEquals(['If you wish to add some of these files, please'\
678
' add them by name.',
682
'ignored 1 file(s) matching "CVS"'],
684
out = self.run_bzr_captured(['add', '-v'], retcode=0)[0]
685
results = sorted(out.rstrip('\n').split('\n'))
686
self.assertEquals(['If you wish to add some of these files, please'\
687
' add them by name.',
688
'ignored CVS matching "CVS"'],
691
def test_add_quiet_is(self):
692
"""add -q does not print the names of added files."""
693
b = Branch.initialize('.')
694
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
695
out = self.run_bzr_captured(['add', '-q'], retcode=0)[0]
696
# the ordering is not defined at the moment
697
results = sorted(out.rstrip('\n').split('\n'))
698
self.assertEquals([''], results)
700
def test_add_in_unversioned(self):
701
"""Try to add a file in an unversioned directory.
703
"bzr add" should add the parent(s) as necessary.
705
from bzrlib.branch import Branch
706
Branch.initialize('.')
707
self.build_tree(['inertiatic/', 'inertiatic/esp'])
708
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
709
self.run_bzr('add', 'inertiatic/esp')
710
self.assertEquals(self.capture('unknowns'), '')
712
# Multiple unversioned parents
713
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
714
self.assertEquals(self.capture('unknowns'), 'veil\n')
715
self.run_bzr('add', 'veil/cerpin/taxt')
716
self.assertEquals(self.capture('unknowns'), '')
718
# Check whacky paths work
719
self.build_tree(['cicatriz/', 'cicatriz/esp'])
720
self.assertEquals(self.capture('unknowns'), 'cicatriz\n')
721
self.run_bzr('add', 'inertiatic/../cicatriz/esp')
722
self.assertEquals(self.capture('unknowns'), '')
724
def test_add_in_versioned(self):
725
"""Try to add a file in a versioned directory.
727
"bzr add" should do this happily.
729
from bzrlib.branch import Branch
730
Branch.initialize('.')
731
self.build_tree(['inertiatic/', 'inertiatic/esp'])
732
self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
733
self.run_bzr('add', '--no-recurse', 'inertiatic')
734
self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n')
735
self.run_bzr('add', 'inertiatic/esp')
736
self.assertEquals(self.capture('unknowns'), '')
738
def test_subdir_add(self):
739
"""Add in subdirectory should add only things from there down"""
740
from bzrlib.branch import Branch
742
eq = self.assertEqual
746
b = Branch.initialize('.')
748
self.build_tree(['src/', 'README'])
750
eq(sorted(t.unknowns()),
753
self.run_bzr('add', 'src')
755
self.build_tree(['src/foo.c'])
760
self.assertEquals(self.capture('unknowns'), 'README\n')
761
eq(len(t.read_working_inventory()), 3)
765
self.assertEquals(self.capture('unknowns'), '')
766
self.run_bzr('check')
768
def test_unknown_command(self):
769
"""Handling of unknown command."""
770
out, err = self.run_bzr_captured(['fluffy-badger'],
772
self.assertEquals(out, '')
773
err.index('unknown command')
775
def create_conflicts(self):
776
"""Create a conflicted tree"""
779
file('hello', 'wb').write("hi world")
780
file('answer', 'wb').write("42")
783
self.runbzr('commit -m base')
784
self.runbzr('branch . ../other')
785
self.runbzr('branch . ../this')
787
file('hello', 'wb').write("Hello.")
788
file('answer', 'wb').write("Is anyone there?")
789
self.runbzr('commit -m other')
791
file('hello', 'wb').write("Hello, world")
792
self.runbzr('mv answer question')
793
file('question', 'wb').write("What do you get when you multiply six"
795
self.runbzr('commit -m this')
797
def test_remerge(self):
798
"""Remerge command works as expected"""
799
self.create_conflicts()
800
self.runbzr('merge ../other --show-base', retcode=1)
801
conflict_text = file('hello').read()
802
assert '|||||||' in conflict_text
803
assert 'hi world' in conflict_text
804
self.runbzr('remerge', retcode=1)
805
conflict_text = file('hello').read()
806
assert '|||||||' not in conflict_text
807
assert 'hi world' not in conflict_text
808
os.unlink('hello.OTHER')
809
self.runbzr('remerge hello --merge-type weave', retcode=1)
810
assert os.path.exists('hello.OTHER')
811
file_id = self.runbzr('file-id hello')
812
file_id = self.runbzr('file-id hello.THIS', retcode=3)
813
self.runbzr('remerge --merge-type weave', retcode=1)
814
assert os.path.exists('hello.OTHER')
815
assert not os.path.exists('hello.BASE')
816
assert '|||||||' not in conflict_text
817
assert 'hi world' not in conflict_text
818
self.runbzr('remerge . --merge-type weave --show-base', retcode=3)
819
self.runbzr('remerge . --merge-type weave --reprocess', retcode=3)
820
self.runbzr('remerge . --show-base --reprocess', retcode=3)
821
self.runbzr('remerge hello --show-base', retcode=1)
822
self.runbzr('remerge hello --reprocess', retcode=1)
823
self.runbzr('resolve --all')
824
self.runbzr('commit -m done',)
825
self.runbzr('remerge', retcode=3)
828
def test_conflicts(self):
829
"""Handling of merge conflicts"""
830
self.create_conflicts()
831
self.runbzr('merge ../other --show-base', retcode=1)
832
conflict_text = file('hello').read()
833
self.assert_('<<<<<<<' in conflict_text)
834
self.assert_('>>>>>>>' in conflict_text)
835
self.assert_('=======' in conflict_text)
836
self.assert_('|||||||' in conflict_text)
837
self.assert_('hi world' in conflict_text)
838
self.runbzr('revert')
839
self.runbzr('resolve --all')
840
self.runbzr('merge ../other', retcode=1)
841
conflict_text = file('hello').read()
842
self.assert_('|||||||' not in conflict_text)
843
self.assert_('hi world' not in conflict_text)
844
result = self.runbzr('conflicts', backtick=1)
845
self.assertEquals(result, "hello\nquestion\n")
846
result = self.runbzr('status', backtick=1)
847
self.assert_("conflicts:\n hello\n question\n" in result, result)
848
self.runbzr('resolve hello')
849
result = self.runbzr('conflicts', backtick=1)
850
self.assertEquals(result, "question\n")
851
self.runbzr('commit -m conflicts', retcode=3)
852
self.runbzr('resolve --all')
853
result = self.runbzr('conflicts', backtick=1)
854
self.runbzr('commit -m conflicts')
855
self.assertEquals(result, "")
857
def test_resign(self):
858
"""Test re signing of data."""
860
oldstrategy = bzrlib.gpg.GPGStrategy
861
branch = Branch.initialize('.')
862
branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
864
# monkey patch gpg signing mechanism
865
from bzrlib.testament import Testament
866
bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
867
self.runbzr('re-sign -r revid:A')
868
self.assertEqual(Testament.from_revision(branch,'A').as_short_text(),
869
branch.revision_store.get('A', 'sig').read())
871
bzrlib.gpg.GPGStrategy = oldstrategy
873
def test_resign_range(self):
875
oldstrategy = bzrlib.gpg.GPGStrategy
876
branch = Branch.initialize('.')
877
branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
878
branch.working_tree().commit("base", allow_pointless=True, rev_id='B')
879
branch.working_tree().commit("base", allow_pointless=True, rev_id='C')
881
# monkey patch gpg signing mechanism
882
from bzrlib.testament import Testament
883
bzrlib.gpg.GPGStrategy = bzrlib.gpg.LoopbackGPGStrategy
884
self.runbzr('re-sign -r 1..')
885
self.assertEqual(Testament.from_revision(branch,'A').as_short_text(),
886
branch.revision_store.get('A', 'sig').read())
887
self.assertEqual(Testament.from_revision(branch,'B').as_short_text(),
888
branch.revision_store.get('B', 'sig').read())
889
self.assertEqual(Testament.from_revision(branch,'C').as_short_text(),
890
branch.revision_store.get('C', 'sig').read())
892
bzrlib.gpg.GPGStrategy = oldstrategy
895
# create a source branch
896
os.mkdir('my-branch')
897
os.chdir('my-branch')
898
self.example_branch()
900
# with no push target, fail
901
self.runbzr('push', retcode=3)
902
# with an explicit target work
903
self.runbzr('push ../output-branch')
904
# with an implicit target work
907
self.runbzr('missing ../output-branch')
908
# advance this branch
909
self.runbzr('commit --unchanged -m unchanged')
911
os.chdir('../output-branch')
912
# There is no longer a difference as long as we have
913
# access to the working tree
916
# But we should be missing a revision
917
self.runbzr('missing ../my-branch', retcode=1)
919
# diverge the branches
920
self.runbzr('commit --unchanged -m unchanged')
921
os.chdir('../my-branch')
923
self.runbzr('push', retcode=3)
924
# and there are difference
925
self.runbzr('missing ../output-branch', retcode=1)
926
self.runbzr('missing --verbose ../output-branch', retcode=1)
927
# but we can force a push
928
self.runbzr('push --overwrite')
930
self.runbzr('missing ../output-branch')
932
# pushing to a new dir with no parent should fail
933
self.runbzr('push ../missing/new-branch', retcode=3)
934
# unless we provide --create-prefix
935
self.runbzr('push --create-prefix ../missing/new-branch')
937
self.runbzr('missing ../missing/new-branch')
939
def test_external_command(self):
940
"""test that external commands can be run by setting the path"""
941
cmd_name = 'test-command'
942
output = 'Hello from test-command'
943
if sys.platform == 'win32':
949
oldpath = os.environ.get('BZRPATH', None)
954
if os.environ.has_key('BZRPATH'):
955
del os.environ['BZRPATH']
957
f = file(cmd_name, 'wb')
958
if sys.platform == 'win32':
959
f.write('@echo off\n')
961
f.write('#!/bin/sh\n')
962
f.write('echo Hello from test-command')
964
os.chmod(cmd_name, 0755)
966
# It should not find the command in the local
967
# directory by default, since it is not in my path
968
bzr(cmd_name, retcode=3)
970
# Now put it into my path
971
os.environ['BZRPATH'] = '.'
974
# The test suite does not capture stdout for external commands
975
# this is because you have to have a real file object
976
# to pass to Popen(stdout=FOO), and StringIO is not one of those.
977
# (just replacing sys.stdout does not change a spawned objects stdout)
978
#self.assertEquals(bzr(cmd_name), output)
980
# Make sure empty path elements are ignored
981
os.environ['BZRPATH'] = os.pathsep
983
bzr(cmd_name, retcode=3)
987
os.environ['BZRPATH'] = oldpath
990
def listdir_sorted(dir):
996
class OldTests(ExternalBase):
997
"""old tests moved from ./testbzr."""
38
self.runcmd(['bzr', 'version'])
42
class HelpCommands(TestBase):
44
self.runcmd('bzr --help')
45
self.runcmd('bzr help')
46
self.runcmd('bzr help commands')
47
self.runcmd('bzr help help')
48
self.runcmd('bzr commit -h')
51
class InitBranch(InTempDir):
54
self.runcmd(['bzr', 'init'])
58
class UserIdentity(InTempDir):
60
# this should always identify something, if only "john@localhost"
61
self.runcmd("bzr whoami")
62
self.runcmd("bzr whoami --email")
63
self.assertEquals(self.backtick("bzr whoami --email").count('@'),
67
class InvalidCommands(InTempDir):
69
self.runcmd("bzr pants", retcode=1)
70
self.runcmd("bzr --pants off", retcode=1)
71
self.runcmd("bzr diff --message foo", retcode=1)
75
class OldTests(InTempDir):
76
# old tests moved from ./testbzr
1000
78
from os import chdir, mkdir
1001
79
from os.path import exists
1003
runbzr = self.runbzr
1004
capture = self.capture
83
backtick = self.backtick
1005
84
progress = self.log
1007
86
progress("basic branch creation")
87
runcmd(['mkdir', 'branch1'])
1012
self.assertEquals(capture('root').rstrip(),
1013
pathjoin(self.test_dir, 'branch1'))
91
self.assertEquals(backtick('bzr root').rstrip(),
92
os.path.join(self.test_dir, 'branch1'))
1015
94
progress("status of new file")
1018
97
f.write('hello world!\n')
1021
self.assertEquals(capture('unknowns'), 'test.txt\n')
1023
out = capture("status")
1024
self.assertEquals(out, 'unknown:\n test.txt\n')
1026
out = capture("status --all")
1027
self.assertEquals(out, "unknown:\n test.txt\n")
1029
out = capture("status test.txt --all")
1030
self.assertEquals(out, "unknown:\n test.txt\n")
100
out = backtick("bzr unknowns")
101
assert out == 'test.txt\n'
103
out = backtick("bzr status")
104
assert out == 'unknown:\n test.txt\n'
106
out = backtick("bzr status --all")
107
assert out == "unknown:\n test.txt\n"
109
out = backtick("bzr status test.txt --all")
110
assert out == "unknown:\n test.txt\n"
1032
112
f = file('test2.txt', 'wt')
1033
113
f.write('goodbye cruel world...\n')
1036
out = capture("status test.txt")
1037
self.assertEquals(out, "unknown:\n test.txt\n")
116
out = backtick("bzr status test.txt")
117
assert out == "unknown:\n test.txt\n"
1039
out = capture("status")
1040
self.assertEquals(out, ("unknown:\n" " test.txt\n" " test2.txt\n"))
119
out = backtick("bzr status")
120
assert out == ("unknown:\n"
1042
124
os.unlink('test2.txt')
1044
126
progress("command aliases")
1045
out = capture("st --all")
1046
self.assertEquals(out, ("unknown:\n" " test.txt\n"))
127
out = backtick("bzr st --all")
128
assert out == ("unknown:\n"
1048
out = capture("stat")
1049
self.assertEquals(out, ("unknown:\n" " test.txt\n"))
131
out = backtick("bzr stat")
132
assert out == ("unknown:\n"
1051
135
progress("command help")
1054
runbzr("help commands")
1055
runbzr("help slartibartfast", 3)
136
runcmd("bzr help st")
138
runcmd("bzr help commands")
139
runcmd("bzr help slartibartfast", 1)
1057
out = capture("help ci")
141
out = backtick("bzr help ci")
1058
142
out.index('aliases: ')
1060
144
progress("can't rename unversioned file")
1061
runbzr("rename test.txt new-test.txt", 3)
145
runcmd("bzr rename test.txt new-test.txt", 1)
1063
147
progress("adding a file")
1065
runbzr("add test.txt")
1066
self.assertEquals(capture("unknowns"), '')
1067
self.assertEquals(capture("status --all"), ("added:\n" " test.txt\n"))
149
runcmd("bzr add test.txt")
150
assert backtick("bzr unknowns") == ''
151
assert backtick("bzr status --all") == ("added:\n"
1069
154
progress("rename newly-added file")
1070
runbzr("rename test.txt hello.txt")
1071
self.assert_(os.path.exists("hello.txt"))
1072
self.assert_(not os.path.exists("test.txt"))
155
runcmd("bzr rename test.txt hello.txt")
156
assert os.path.exists("hello.txt")
157
assert not os.path.exists("test.txt")
1074
self.assertEquals(capture("revno"), '0\n')
159
assert backtick("bzr revno") == '0\n'
1076
161
progress("add first revision")
1077
runbzr(['commit', '-m', 'add first revision'])
162
runcmd(["bzr", "commit", "-m", 'add first revision'])
1079
164
progress("more complex renames")
1080
165
os.mkdir("sub1")
1081
runbzr("rename hello.txt sub1", 3)
1082
runbzr("rename hello.txt sub1/hello.txt", 3)
1083
runbzr("move hello.txt sub1", 3)
1086
runbzr("rename sub1 sub2")
1087
runbzr("move hello.txt sub2")
1088
self.assertEqual(capture("relpath sub2/hello.txt"),
1089
pathjoin("sub2", "hello.txt\n"))
1091
self.assert_(exists("sub2"))
1092
self.assert_(exists("sub2/hello.txt"))
1093
self.assert_(not exists("sub1"))
1094
self.assert_(not exists("hello.txt"))
1096
runbzr(['commit', '-m', 'commit with some things moved to subdirs'])
166
runcmd("bzr rename hello.txt sub1", 1)
167
runcmd("bzr rename hello.txt sub1/hello.txt", 1)
168
runcmd("bzr move hello.txt sub1", 1)
170
runcmd("bzr add sub1")
171
runcmd("bzr rename sub1 sub2")
172
runcmd("bzr move hello.txt sub2")
173
assert backtick("bzr relpath sub2/hello.txt") == os.path.join("sub2", "hello.txt\n")
175
assert exists("sub2")
176
assert exists("sub2/hello.txt")
177
assert not exists("sub1")
178
assert not exists("hello.txt")
180
runcmd(['bzr', 'commit', '-m', 'commit with some things moved to subdirs'])
1100
runbzr('move sub2/hello.txt sub1')
1101
self.assert_(not exists('sub2/hello.txt'))
1102
self.assert_(exists('sub1/hello.txt'))
1103
runbzr('move sub2 sub1')
1104
self.assert_(not exists('sub2'))
1105
self.assert_(exists('sub1/sub2'))
183
runcmd('bzr add sub1')
184
runcmd('bzr move sub2/hello.txt sub1')
185
assert not exists('sub2/hello.txt')
186
assert exists('sub1/hello.txt')
187
runcmd('bzr move sub2 sub1')
188
assert not exists('sub2')
189
assert exists('sub1/sub2')
1107
runbzr(['commit', '-m', 'rename nested subdirectories'])
191
runcmd(['bzr', 'commit', '-m', 'rename nested subdirectories'])
1109
193
chdir('sub1/sub2')
1110
self.assertEquals(capture('root')[:-1],
1111
pathjoin(self.test_dir, 'branch1'))
1112
runbzr('move ../hello.txt .')
1113
self.assert_(exists('./hello.txt'))
1114
self.assertEquals(capture('relpath hello.txt'),
1115
pathjoin('sub1', 'sub2', 'hello.txt') + '\n')
1116
self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
1117
runbzr(['commit', '-m', 'move to parent directory'])
194
self.assertEquals(backtick('bzr root')[:-1],
195
os.path.join(self.test_dir, 'branch1'))
196
runcmd('bzr move ../hello.txt .')
197
assert exists('./hello.txt')
198
assert backtick('bzr relpath hello.txt') == os.path.join('sub1', 'sub2', 'hello.txt\n')
199
assert backtick('bzr relpath ../../sub1/sub2/hello.txt') == os.path.join('sub1', 'sub2', 'hello.txt\n')
200
runcmd(['bzr', 'commit', '-m', 'move to parent directory'])
1119
self.assertEquals(capture('relpath sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
202
assert backtick('bzr relpath sub2/hello.txt') == os.path.join('sub1', 'sub2', 'hello.txt\n')
1121
runbzr('move sub2/hello.txt .')
1122
self.assert_(exists('hello.txt'))
204
runcmd('bzr move sub2/hello.txt .')
205
assert exists('hello.txt')
1124
207
f = file('hello.txt', 'wt')
1125
208
f.write('some nice new content\n')
1128
211
f = file('msg.tmp', 'wt')
1129
f.write('this is my new commit\nand it has multiple lines, for fun')
212
f.write('this is my new commit\n')
1132
runbzr('commit -F msg.tmp')
1134
self.assertEquals(capture('revno'), '5\n')
1135
runbzr('export -r 5 export-5.tmp')
1136
runbzr('export export.tmp')
1140
runbzr('log -v --forward')
1141
runbzr('log -m', retcode=3)
1142
log_out = capture('log -m commit')
1143
self.assert_("this is my new commit\n and" in log_out)
1144
self.assert_("rename nested" not in log_out)
1145
self.assert_('revision-id' not in log_out)
1146
self.assert_('revision-id' in capture('log --show-ids -m commit'))
1148
log_out = capture('log --line')
1149
for line in log_out.splitlines():
1150
self.assert_(len(line) <= 79, len(line))
1151
self.assert_("this is my new commit and" in log_out)
215
runcmd('bzr commit -F msg.tmp')
217
assert backtick('bzr revno') == '5\n'
218
runcmd('bzr export -r 5 export-5.tmp')
219
runcmd('bzr export export.tmp')
1154
226
progress("file with spaces in name")
1155
227
mkdir('sub directory')
1156
228
file('sub directory/file with spaces ', 'wt').write('see how this works\n')
1158
runbzr('diff', retcode=1)
1159
runbzr('commit -m add-spaces')
1163
runbzr('log --forward')
1168
progress("symlinks")
1172
os.symlink("NOWHERE1", "link1")
1174
self.assertEquals(self.capture('unknowns'), '')
1175
runbzr(['commit', '-m', '1: added symlink link1'])
1179
self.assertEquals(self.capture('unknowns'), '')
1180
os.symlink("NOWHERE2", "d1/link2")
1181
self.assertEquals(self.capture('unknowns'), 'd1/link2\n')
1182
# is d1/link2 found when adding d1
1184
self.assertEquals(self.capture('unknowns'), '')
1185
os.symlink("NOWHERE3", "d1/link3")
1186
self.assertEquals(self.capture('unknowns'), 'd1/link3\n')
1187
runbzr(['commit', '-m', '2: added dir, symlink'])
1189
runbzr('rename d1 d2')
1190
runbzr('move d2/link2 .')
1191
runbzr('move link1 d2')
1192
self.assertEquals(os.readlink("./link2"), "NOWHERE2")
1193
self.assertEquals(os.readlink("d2/link1"), "NOWHERE1")
1194
runbzr('add d2/link3')
1195
runbzr('diff', retcode=1)
1196
runbzr(['commit', '-m', '3: rename of dir, move symlinks, add link3'])
1199
os.symlink("TARGET 2", "link2")
1200
os.unlink("d2/link1")
1201
os.symlink("TARGET 1", "d2/link1")
1202
runbzr('diff', retcode=1)
1203
self.assertEquals(self.capture("relpath d2/link1"), "d2/link1\n")
1204
runbzr(['commit', '-m', '4: retarget of two links'])
1206
runbzr('remove d2/link1')
1207
self.assertEquals(self.capture('unknowns'), 'd2/link1\n')
1208
runbzr(['commit', '-m', '5: remove d2/link1'])
1209
# try with the rm alias
1210
runbzr('add d2/link1')
1211
runbzr(['commit', '-m', '6: add d2/link1'])
1212
runbzr('rm d2/link1')
1213
self.assertEquals(self.capture('unknowns'), 'd2/link1\n')
1214
runbzr(['commit', '-m', '7: remove d2/link1'])
1218
runbzr('rename d2/link3 d1/link3new')
1219
self.assertEquals(self.capture('unknowns'), 'd2/link1\n')
1220
runbzr(['commit', '-m', '8: remove d2/link1, move/rename link3'])
1224
runbzr(['export', '-r', '1', 'exp1.tmp'])
1226
self.assertEquals(listdir_sorted("."), [ "link1" ])
1227
self.assertEquals(os.readlink("link1"), "NOWHERE1")
1230
runbzr(['export', '-r', '2', 'exp2.tmp'])
1232
self.assertEquals(listdir_sorted("."), [ "d1", "link1" ])
1235
runbzr(['export', '-r', '3', 'exp3.tmp'])
1237
self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
1238
self.assertEquals(listdir_sorted("d2"), [ "link1", "link3" ])
1239
self.assertEquals(os.readlink("d2/link1"), "NOWHERE1")
1240
self.assertEquals(os.readlink("link2") , "NOWHERE2")
1243
runbzr(['export', '-r', '4', 'exp4.tmp'])
1245
self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
1246
self.assertEquals(os.readlink("d2/link1"), "TARGET 1")
1247
self.assertEquals(os.readlink("link2") , "TARGET 2")
1248
self.assertEquals(listdir_sorted("d2"), [ "link1", "link3" ])
1251
runbzr(['export', '-r', '5', 'exp5.tmp'])
1253
self.assertEquals(listdir_sorted("."), [ "d2", "link2" ])
1254
self.assert_(os.path.islink("link2"))
1255
self.assert_(listdir_sorted("d2")== [ "link3" ])
1258
runbzr(['export', '-r', '8', 'exp6.tmp'])
1260
self.assertEqual(listdir_sorted("."), [ "d1", "d2", "link2"])
1261
self.assertEquals(listdir_sorted("d1"), [ "link3new" ])
1262
self.assertEquals(listdir_sorted("d2"), [])
1263
self.assertEquals(os.readlink("d1/link3new"), "NOWHERE3")
1266
progress("skipping symlink tests")
1269
class HttpTests(TestCaseWithWebserver):
1270
"""Test bzr ui commands against remote branches."""
1272
def test_branch(self):
1274
branch = Branch.initialize('from')
1275
branch.working_tree().commit('empty commit for nonsense', allow_pointless=True)
1276
url = self.get_remote_url('from')
1277
self.run_bzr('branch', url, 'to')
1278
branch = Branch.open('to')
1279
self.assertEqual(1, len(branch.revision_history()))
1282
self.build_tree(['branch/', 'branch/file'])
1283
branch = Branch.initialize('branch')
1284
branch.working_tree().add(['file'])
1285
branch.working_tree().commit('add file', rev_id='A')
1286
url = self.get_remote_url('branch/file')
1287
output = self.capture('log %s' % url)
1288
self.assertEqual(8, len(output.split('\n')))
231
runcmd('bzr commit -m add-spaces')
235
runcmd('bzr log --forward')
247
# Can't create a branch if it already exists
248
runcmd('bzr branch branch1', retcode=1)
249
# Can't create a branch if its parent doesn't exist
250
runcmd('bzr branch /unlikely/to/exist', retcode=1)
251
runcmd('bzr branch branch1 branch2')
255
runcmd('bzr pull', retcode=1)
256
runcmd('bzr pull ../branch2')
259
runcmd('bzr commit -m empty')
261
chdir('../../branch2')
263
runcmd('bzr commit -m empty')
265
runcmd('bzr commit -m empty')
266
runcmd('bzr pull', retcode=1)
269
progress('status after remove')
270
mkdir('status-after-remove')
271
# see mail from William Dodé, 2005-05-25
272
# $ bzr init; touch a; bzr add a; bzr commit -m "add a"
273
# * looking for changes...
278
# bzr: local variable 'kind' referenced before assignment
279
# at /vrac/python/bazaar-ng/bzrlib/diff.py:286 in compare_trees()
280
# see ~/.bzr.log for debug information
281
chdir('status-after-remove')
283
file('a', 'w').write('foo')
285
runcmd(['bzr', 'commit', '-m', 'add a'])
286
runcmd('bzr remove a')
291
progress('ignore patterns')
292
mkdir('ignorebranch')
293
chdir('ignorebranch')
295
assert backtick('bzr unknowns') == ''
297
file('foo.tmp', 'wt').write('tmp files are ignored')
298
assert backtick('bzr unknowns') == ''
300
file('foo.c', 'wt').write('int main() {}')
301
assert backtick('bzr unknowns') == 'foo.c\n'
302
runcmd('bzr add foo.c')
303
assert backtick('bzr unknowns') == ''
305
# 'ignore' works when creating the .bzignore file
306
file('foo.blah', 'wt').write('blah')
307
assert backtick('bzr unknowns') == 'foo.blah\n'
308
runcmd('bzr ignore *.blah')
309
assert backtick('bzr unknowns') == ''
310
assert file('.bzrignore', 'rb').read() == '*.blah\n'
312
# 'ignore' works when then .bzrignore file already exists
313
file('garh', 'wt').write('garh')
314
assert backtick('bzr unknowns') == 'garh\n'
315
runcmd('bzr ignore garh')
316
assert backtick('bzr unknowns') == ''
317
assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
324
progress("recursive and non-recursive add")
329
fp = os.path.join('foo', 'test.txt')
333
runcmd('bzr add --no-recurse foo')
334
runcmd('bzr file-id foo')
335
runcmd('bzr file-id ' + fp, 1) # not versioned yet
336
runcmd('bzr commit -m add-dir-only')
338
runcmd('bzr file-id ' + fp, 1) # still not versioned
340
runcmd('bzr add foo')
341
runcmd('bzr file-id ' + fp)
342
runcmd('bzr commit -m add-sub-file')
1290
def test_check(self):
1291
self.build_tree(['branch/', 'branch/file'])
1292
branch = Branch.initialize('branch')
1293
branch.working_tree().add(['file'])
1294
branch.working_tree().commit('add file', rev_id='A')
1295
url = self.get_remote_url('branch/')
1296
self.run_bzr('check', url)
352
# lists all tests from this module in the best order to run them. we
353
# do it this way rather than just discovering them all because it
354
# allows us to test more basic functions first where failures will be
355
# easiest to understand.
358
from unittest import TestSuite
360
s.addTests([TestVersion(),