15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Black-box tests for bzr log."""
18
"""Black-box tests for brz log."""
20
20
from itertools import izip
30
from bzrlib.tests import (
30
from breezy.tests import (
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
34
from breezy.tests.matchers import ContainsNoVfsCalls
37
37
class TestLog(tests.TestCaseWithTransport, test_log.TestLogMixin):
341
341
def test_log_zero_revspec(self):
342
342
self.make_minimal_branch()
343
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'],
343
self.run_bzr_error(['brz: ERROR: Logging revision 0 is invalid.'],
346
346
def test_log_zero_begin_revspec(self):
347
347
self.make_linear_branch()
348
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'],
348
self.run_bzr_error(['brz: ERROR: Logging revision 0 is invalid.'],
349
349
['log', '-r0..2'])
351
351
def test_log_zero_end_revspec(self):
352
352
self.make_linear_branch()
353
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'],
353
self.run_bzr_error(['brz: ERROR: Logging revision 0 is invalid.'],
354
354
['log', '-r-2..0'])
356
356
def test_log_nonexistent_revno(self):
357
357
self.make_minimal_branch()
358
self.run_bzr_error(["bzr: ERROR: Requested revision: '1234' "
358
self.run_bzr_error(["brz: ERROR: Requested revision: '1234' "
359
359
"does not exist in branch:"],
360
360
['log', '-r1234'])
362
362
def test_log_nonexistent_dotted_revno(self):
363
363
self.make_minimal_branch()
364
self.run_bzr_error(["bzr: ERROR: Requested revision: '123.123' "
364
self.run_bzr_error(["brz: ERROR: Requested revision: '123.123' "
365
365
"does not exist in branch:"],
366
366
['log', '-r123.123'])
368
368
def test_log_change_nonexistent_revno(self):
369
369
self.make_minimal_branch()
370
self.run_bzr_error(["bzr: ERROR: Requested revision: '1234' "
370
self.run_bzr_error(["brz: ERROR: Requested revision: '1234' "
371
371
"does not exist in branch:"],
372
372
['log', '-c1234'])
374
374
def test_log_change_nonexistent_dotted_revno(self):
375
375
self.make_minimal_branch()
376
self.run_bzr_error(["bzr: ERROR: Requested revision: '123.123' "
376
self.run_bzr_error(["brz: ERROR: Requested revision: '123.123' "
377
377
"does not exist in branch:"],
378
378
['log', '-c123.123'])
380
380
def test_log_change_single_revno_only(self):
381
381
self.make_minimal_branch()
382
self.run_bzr_error(['bzr: ERROR: Option --change does not'
382
self.run_bzr_error(['brz: ERROR: Option --change does not'
383
383
' accept revision ranges'],
384
384
['log', '--change', '2..3'])
386
386
def test_log_change_incompatible_with_revision(self):
387
self.run_bzr_error(['bzr: ERROR: --revision and --change'
387
self.run_bzr_error(['brz: ERROR: --revision and --change'
388
388
' are mutually exclusive'],
389
389
['log', '--change', '2', '--revision', '3'])
400
400
def test_log_reversed_revspecs(self):
401
401
self.make_linear_branch()
402
self.run_bzr_error(('bzr: ERROR: Start revision must be older than '
402
self.run_bzr_error(('brz: ERROR: Start revision must be older than '
403
403
'the end revision.\n',),
404
404
['log', '-r3..1'])
406
406
def test_log_reversed_dotted_revspecs(self):
407
407
self.make_merged_branch()
408
self.run_bzr_error(('bzr: ERROR: Start revision not found in '
408
self.run_bzr_error(('brz: ERROR: Start revision not found in '
409
409
'history of end revision.\n',),
410
410
"log -r 1.1.1..1")
423
423
def test_log_unsupported_timezone(self):
424
424
self.make_linear_branch()
425
self.run_bzr_error(['bzr: ERROR: Unsupported timezone format "foo", '
425
self.run_bzr_error(['brz: ERROR: Unsupported timezone format "foo", '
426
426
'options are "utc", "original", "local".'],
427
427
['log', '--timezone', 'foo'])
429
429
def test_log_exclude_ancestry_no_range(self):
430
430
self.make_linear_branch()
431
self.run_bzr_error(['bzr: ERROR: --exclude-common-ancestry'
431
self.run_bzr_error(['brz: ERROR: --exclude-common-ancestry'
432
432
' requires -r with two revisions'],
433
433
['log', '--exclude-common-ancestry'])
435
435
def test_log_exclude_ancestry_single_revision(self):
436
436
self.make_merged_branch()
437
self.run_bzr_error(['bzr: ERROR: --exclude-common-ancestry'
437
self.run_bzr_error(['brz: ERROR: --exclude-common-ancestry'
438
438
' requires two different revisions'],
439
439
['log', '--exclude-common-ancestry',
440
440
'-r1.1.1..1.1.1'])
566
566
def test_include_merges(self):
567
567
# Confirm --include-merges gives the same output as -n0
568
msg = ("The option '--include-merges' to 'bzr log' "
569
"has been deprecated in bzr 2.5. "
568
msg = ("The option '--include-merges' to 'brz log' "
569
"has been deprecated in brz 2.5. "
570
570
"Please use '--include-merged' instead.\n")
571
571
self.assertLogRevnos(['--include-merges'],
572
572
['2', '1.1.2', '1.2.1', '1.1.1', '1'],
771
771
self.overrideAttr(osutils, '_cached_user_encoding')
773
773
def create_branch(self):
776
776
self.build_tree_contents([('a', 'some stuff\n')])
778
bzr(['commit', '-m', self._message])
778
brz(['commit', '-m', self._message])
780
780
def try_encoding(self, encoding, fail=False):
783
783
self.assertRaises(UnicodeEncodeError,
784
784
self._mu.encode, encoding)
789
789
old_encoding = osutils._cached_user_encoding
790
790
# This test requires that 'run_bzr' uses the current
791
# bzrlib, because we override user_encoding, and expect
791
# breezy, because we override user_encoding, and expect
794
794
osutils._cached_user_encoding = 'ascii'
795
795
# We should be able to handle any encoding
796
out, err = bzr('log', encoding=encoding)
796
out, err = brz('log', encoding=encoding)
798
798
# Make sure we wrote mu as we expected it to exist
799
799
self.assertNotEqual(-1, out.find(encoded_msg))
817
817
self.try_encoding(encoding, fail=True)
819
819
def test_stdout_encoding(self):
821
821
osutils._cached_user_encoding = "cp1251"
824
824
self.build_tree(['a'])
826
bzr(['commit', '-m', u'\u0422\u0435\u0441\u0442'])
826
brz(['commit', '-m', u'\u0422\u0435\u0441\u0442'])
827
827
stdout, stderr = self.run_bzr('log', encoding='cp866')
829
829
message = stdout.splitlines()[-1]
1018
1018
(stdout, stderr) = self.run_bzr(['log', '-r..2'], retcode=3)
1019
1019
self.assertEqual(["2", "1"],
1020
1020
[r.revno for r in self.get_captured_revisions()])
1021
self.assertEqual("bzr: ERROR: Further revision history missing.", stderr)
1021
self.assertEqual("brz: ERROR: Further revision history missing.", stderr)
1023
1023
def test_log_range_open_end(self):
1024
1024
self.assertLogRevnos(["-r1.."], ["2", "1"])