100
100
def test_cat(self):
101
101
# bzr cat shouldn't change the contents
102
102
# using run_bzr since that doesn't decode
103
txt = self.run_bzr('cat', 'b')[0]
103
txt = self.run_bzr('cat b')[0]
104
104
self.assertEqual('non-ascii \xFF\xFF\xFC\xFB\x00 in b\n', txt)
106
txt = self.run_bzr('cat', self.info['filename'])[0]
106
txt = self.run_bzr(['cat', self.info['filename']])[0]
107
107
self.assertEqual('unicode filename\n', txt)
109
109
def test_cat_revision(self):
110
110
bzr = self.run_bzr_decode
112
112
committer = self.info['committer']
113
txt = bzr('cat-revision', '-r', '1')
113
txt = bzr('cat-revision -r 1')
114
114
self.failUnless(committer in txt,
115
115
'failed to find %r in %r' % (committer, txt))
117
117
msg = self.info['message']
118
txt = bzr('cat-revision', '-r', '2')
118
txt = bzr('cat-revision -r 2')
119
119
self.failUnless(msg in txt, 'failed to find %r in %r' % (msg, txt))
121
121
def test_mkdir(self):
122
122
bzr = self.run_bzr_decode
124
txt = bzr('mkdir', self.info['directory'])
124
txt = bzr(['mkdir', self.info['directory']])
125
125
self.assertEqual(u'added %s\n' % self.info['directory'], txt)
127
127
# The text should be garbled, but the command should succeed
128
txt = bzr('mkdir', self.info['directory'] + '2', encoding='ascii')
128
txt = bzr(['mkdir', self.info['directory'] + '2'], encoding='ascii')
129
129
expected = u'added %s2\n' % (self.info['directory'],)
130
130
expected = expected.encode('ascii', 'replace')
131
131
self.assertEqual(expected, txt)
133
133
def test_relpath(self):
134
134
bzr = self.run_bzr_decode
136
txt = bzr('relpath', self.info['filename'])
136
txt = bzr(['relpath', self.info['filename']])
137
137
self.assertEqual(self.info['filename'] + '\n', txt)
139
bzr('relpath', self.info['filename'], encoding='ascii', retcode=3)
139
bzr(['relpath', self.info['filename']], encoding='ascii', retcode=3)
141
141
def test_inventory(self):
142
142
bzr = self.run_bzr_decode
151
151
# We don't really care about the ids themselves,
152
152
# but the command shouldn't fail
153
txt = bzr('inventory', '--show-ids')
153
txt = bzr('inventory --show-ids')
155
155
def test_revno(self):
156
156
# There isn't a lot to test here, since revno should always
163
163
def test_revision_info(self):
164
164
bzr = self.run_bzr_decode
166
bzr('revision-info', '-r', '1')
166
bzr('revision-info -r 1')
168
168
# TODO: jam 20060105 If we support revisions with non-ascii characters,
169
169
# this should be strict and fail.
170
bzr('revision-info', '-r', '1', encoding='ascii')
170
bzr('revision-info -r 1', encoding='ascii')
172
172
def test_mv(self):
173
173
bzr = self.run_bzr_decode
177
177
dirname = self.info['directory']
179
179
# fname1 already exists
180
bzr('mv', 'a', fname1, retcode=3)
180
bzr(['mv', 'a', fname1], retcode=3)
182
txt = bzr('mv', 'a', fname2)
182
txt = bzr(['mv', 'a', fname2])
183
183
self.assertEqual(u'a => %s\n' % fname2, txt)
184
184
self.failIfExists('a')
185
185
self.failUnlessExists(fname2)
191
191
os.mkdir(dirname)
192
192
self.wt.add(dirname)
193
txt = bzr('mv', fname1, fname2, dirname)
193
txt = bzr(['mv', fname1, fname2, dirname])
194
194
self.assertEqual([u'%s => %s/%s' % (fname1, dirname, fname1),
195
195
u'%s => %s/%s' % (fname2, dirname, fname2)]
196
196
, txt.splitlines())
198
198
# The rename should still succeed
199
199
newpath = u'%s/%s' % (dirname, fname2)
200
txt = bzr('mv', newpath, 'a', encoding='ascii')
200
txt = bzr(['mv', newpath, 'a'], encoding='ascii')
201
201
self.failUnlessExists('a')
202
202
self.assertEqual(newpath.encode('ascii', 'replace') + ' => a\n', txt)
205
205
# We should be able to branch into a directory that
206
206
# has a unicode name, even if we can't display the name
207
207
bzr = self.run_bzr_decode
208
bzr('branch', u'.', self.info['directory'])
209
bzr('branch', u'.', self.info['directory'] + '2', encoding='ascii')
208
bzr(['branch', u'.', self.info['directory']])
209
bzr(['branch', u'.', self.info['directory'] + '2'], encoding='ascii')
211
211
def test_pull(self):
212
212
# Make sure we can pull from paths that can't be encoded
238
238
os.chdir('../' + dirname2)
239
239
# We should be able to pull, even if our encoding is bad
240
bzr('pull', '--verbose', encoding='ascii')
240
bzr('pull --verbose', encoding='ascii')
242
242
def test_push(self):
243
243
# TODO: Test push to an SFTP location
268
268
self.wt.commit('Added some ' + dirname)
269
bzr('push', '--verbose', encoding='ascii')
271
bzr('push', '--verbose', dirname + '2')
273
bzr('push', '--verbose', dirname + '3', encoding='ascii')
275
bzr('push', '--verbose', '--create-prefix', dirname + '4/' + dirname + '5')
276
bzr('push', '--verbose', '--create-prefix', dirname + '6/' + dirname + '7', encoding='ascii')
269
bzr('push --verbose', encoding='ascii')
271
bzr(['push', '--verbose', dirname + '2'])
273
bzr(['push', '--verbose', dirname + '3'], encoding='ascii')
275
bzr(['push', '--verbose', '--create-prefix',
276
dirname + '4/' + dirname + '5'])
277
bzr(['push', '--verbose', '--create-prefix',
278
dirname + '6/' + dirname + '7'], encoding='ascii')
278
280
def test_renames(self):
279
281
bzr = self.run_bzr_decode
281
283
fname = self.info['filename'] + '2'
282
bzr('mv', 'a', fname)
284
bzr(['mv', 'a', fname])
283
285
txt = bzr('renames')
284
286
self.assertEqual(u'a => %s\n' % fname, txt)
289
291
bzr = self.run_bzr_decode
291
293
fname = self.info['filename']
292
txt = bzr('remove', fname, encoding='ascii')
294
txt = bzr(['remove', fname], encoding='ascii')
294
296
def test_remove_verbose(self):
295
297
bzr = self.run_bzr_decode
297
299
fname = self.info['filename']
298
txt = bzr('remove', '--verbose', fname, encoding='ascii')
300
txt = bzr(['remove', '--verbose', fname], encoding='ascii')
300
302
def test_file_id(self):
301
303
bzr = self.run_bzr_decode
303
305
fname = self.info['filename']
304
txt = bzr('file-id', fname)
306
txt = bzr(['file-id', fname])
306
308
# TODO: jam 20060106 We don't support non-ascii file ids yet,
307
309
# so there is nothing which would fail in ascii encoding
308
310
# This *should* be retcode=3
309
txt = bzr('file-id', fname, encoding='ascii')
311
txt = bzr(['file-id', fname], encoding='ascii')
311
313
def test_file_path(self):
312
314
bzr = self.run_bzr_decode
322
324
self.wt.rename_one(fname, path)
323
325
self.wt.commit('moving things around')
325
txt = bzr('file-path', path)
327
txt = bzr(['file-path', path])
327
329
# TODO: jam 20060106 We don't support non-ascii file ids yet,
328
330
# so there is nothing which would fail in ascii encoding
329
331
# This *should* be retcode=3
330
txt = bzr('file-path', path, encoding='ascii')
332
txt = bzr(['file-path', path], encoding='ascii')
332
334
def test_revision_history(self):
333
335
bzr = self.run_bzr_decode
360
362
txt = bzr('deleted')
361
363
self.assertEqual(fname+'\n', txt)
363
txt = bzr('deleted', '--show-ids')
365
txt = bzr('deleted --show-ids')
364
366
self.failUnless(txt.startswith(fname))
366
368
# Deleted should fail if cannot decode
416
418
self.assertNotEqual(-1, txt.find(self.info['committer']))
417
419
self.assertNotEqual(-1, txt.find(self.info['message']))
419
txt = bzr('log', '--verbose')
421
txt = bzr('log --verbose')
420
422
self.assertNotEqual(-1, txt.find(fname))
422
424
# Make sure log doesn't fail even if we can't write out
423
txt = bzr('log', '--verbose', encoding='ascii')
425
txt = bzr('log --verbose', encoding='ascii')
424
426
self.assertEqual(-1, txt.find(fname))
425
427
self.assertNotEqual(-1, txt.find(fname.encode('ascii', 'replace')))
428
430
bzr = self.run_bzr_decode
430
432
fname = self.info['filename']
431
txt = bzr('touching-revisions', fname)
433
txt = bzr(['touching-revisions', fname])
432
434
self.assertEqual(u' 3 added %s\n' % (fname,), txt)
434
436
fname2 = self.info['filename'] + '2'
435
437
self.wt.rename_one(fname, fname2)
436
438
self.wt.commit(u'Renamed %s => %s' % (fname, fname2))
438
txt = bzr('touching-revisions', fname2)
440
txt = bzr(['touching-revisions', fname2])
439
441
expected_txt = (u' 3 added %s\n'
440
442
u' 4 renamed %s => %s\n'
441
443
% (fname, fname, fname2))
442
444
self.assertEqual(expected_txt, txt)
444
bzr('touching-revisions', fname2, encoding='ascii', retcode=3)
446
bzr(['touching-revisions', fname2], encoding='ascii', retcode=3)
446
448
def test_ls(self):
447
449
bzr = self.run_bzr_decode
450
452
self.assertEqual(sorted(['a', 'b', self.info['filename']]),
451
453
sorted(txt.splitlines()))
452
txt = bzr('ls', '--null')
454
txt = bzr('ls --null')
453
455
self.assertEqual(sorted(['', 'a', 'b', self.info['filename']]),
454
456
sorted(txt.split('\0')))
456
458
txt = bzr('ls', encoding='ascii', retcode=3)
457
txt = bzr('ls', '--null', encoding='ascii', retcode=3)
459
txt = bzr('ls --null', encoding='ascii', retcode=3)
459
461
def test_unknowns(self):
460
462
bzr = self.run_bzr_decode
481
483
check_unknowns([fname2])
483
bzr('ignore', './' + fname2)
485
bzr(['ignore', './' + fname2])
484
486
# After 'ignore' you must re-open the working tree
485
487
self.wt = self.wt.bzrdir.open_workingtree()
486
488
check_unknowns([])
492
494
# Ignore should not care what the encoding is
493
495
# (right now it doesn't print anything)
494
bzr('ignore', fname3, encoding='ascii')
496
bzr(['ignore', fname3], encoding='ascii')
495
497
self.wt = self.wt.bzrdir.open_workingtree()
496
498
check_unknowns([])
498
500
# Now try a wildcard match
499
501
fname4 = self.info['filename'] + '4.txt'
500
502
open(fname4, 'wb').write('unknown 4\n')
501
bzr('ignore', '*.txt')
502
504
self.wt = self.wt.bzrdir.open_workingtree()
503
505
check_unknowns([])
505
507
# and a different wildcard that matches everything
506
508
os.remove('.bzrignore')
507
bzr('ignore', self.info['filename'] + '*')
509
bzr(['ignore', self.info['filename'] + '*'])
508
510
self.wt = self.wt.bzrdir.open_workingtree()
509
511
check_unknowns([])
512
514
bzr = self.run_bzr_decode
514
516
# create empty tree as reference for missing
515
self.run_bzr('init', 'empty-tree')
517
self.run_bzr('init empty-tree')
517
519
msg = self.info['message']
519
txt = bzr('missing', 'empty-tree', retcode=1)
521
txt = bzr('missing empty-tree', retcode=1)
520
522
self.assertNotEqual(-1, txt.find(self.info['committer']))
521
523
self.assertNotEqual(-1, txt.find(msg))
523
525
# Make sure missing doesn't fail even if we can't write out
524
txt = bzr('missing', 'empty-tree', encoding='ascii', retcode=1)
526
txt = bzr('missing empty-tree', encoding='ascii', retcode=1)
525
527
self.assertEqual(-1, txt.find(msg))
526
528
self.assertNotEqual(-1, txt.find(msg.encode('ascii', 'replace')))