1
# Copyright (C) 2005-2010 Canonical Ltd
1
# Copyright (C) 2005-2011 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
251
250
wt.commit(message='add file1 and file2')
252
251
self.run_bzr('branch parent child')
253
252
os.unlink('child/file1')
254
file('child/file2', 'wb').write('hello\n')
253
with file('child/file2', 'wb') as f: f.write('hello\n')
255
254
self.run_bzr(['commit', '-m', 'remove file1 and modify file2',
257
256
os.chdir('parent')
323
322
1 Joe Foo\t2005-11-22
326
Use --include-merges or -n0 to see merged revisions.
325
Use --include-merged or -n0 to see merged revisions.
328
327
wt.branch, log.ShortLogFormatter,
329
328
formatter_kwargs=dict(show_advice=True))
1335
1334
self.assertFormatterResult("""\
1336
1335
------------------------------------------------------------
1338
fixes bug(s): test://bug/id test://bug/2
1337
fixes bugs: test://bug/id test://bug/2
1339
1338
author: Joe Bar <joe@bar.com>
1340
1339
committer: Joe Foo <joe@foo.com>
1341
1340
branch nick: work
1359
1358
tree = self.make_commits_with_bugs()
1360
1359
self.assertFormatterResult("""\
1361
1360
2 Joe Bar\t2005-11-22
1362
fixes bug(s): test://bug/id test://bug/2
1361
fixes bugs: test://bug/id test://bug/2
1367
1366
1 Joe Foo\t2005-11-22
1368
fixes bug(s): test://bug/id
1367
fixes bug: test://bug/id
1369
1368
simple log message
1537
1536
def make_branch_with_alternate_ancestries(self, relpath='.'):
1538
1537
# See test_merge_sorted_exclude_ancestry below for the difference with
1539
1538
# bt.per_branch.test_iter_merge_sorted_revision.
1540
# TestIterMergeSortedRevisionsBushyGraph.
1539
# TestIterMergeSortedRevisionsBushyGraph.
1541
1540
# make_branch_with_alternate_ancestries
1542
1541
# and test_merge_sorted_exclude_ancestry
1543
1542
# See the FIXME in assertLogRevnos too.
1570
1569
def assertLogRevnos(self, expected_revnos, b, start, end,
1571
1570
exclude_common_ancestry, generate_merge_revisions=True):
1572
1571
# FIXME: the layering in log makes it hard to test intermediate levels,
1573
# I wish adding filters with their parameters were easier...
1572
# I wish adding filters with their parameters was easier...
1574
1573
# -- vila 20100413
1575
1574
iter_revs = log._calc_view_revisions(
1576
1575
b, start, end, direction='reverse',
1598
1597
b, '1', '3', exclude_common_ancestry=True,
1599
1598
generate_merge_revisions=True)
1601
class TestLogDefaults(TestCaseForLogFormatter):
1602
def test_default_log_level(self):
1604
Test to ensure that specifying 'levels=1' to make_log_request_dict
1605
doesn't get overwritten when using a LogFormatter that supports more
1609
wt = self._prepare_tree_with_merges()
1612
class CustomLogFormatter(log.LogFormatter):
1613
def __init__(self, *args, **kwargs):
1614
super(CustomLogFormatter, self).__init__(*args, **kwargs)
1616
def get_levels(self):
1617
# log formatter supports all levels:
1619
def log_revision(self, revision):
1620
self.revisions.append(revision)
1622
log_formatter = LogCatcher()
1623
# First request we don't specify number of levels, we should get a
1624
# sensible default (whatever the LogFormatter handles - which in this
1625
# case is 0/everything):
1626
request = log.make_log_request_dict(limit=10)
1627
log.Logger(b, request).show(log_formatter)
1628
# should have all three revisions:
1629
self.assertEquals(len(log_formatter.revisions), 3)
1632
log_formatter = LogCatcher()
1633
# now explicitly request mainline revisions only:
1634
request = log.make_log_request_dict(limit=10, levels=1)
1635
log.Logger(b, request).show(log_formatter)
1636
# should now only have 2 revisions:
1637
self.assertEquals(len(log_formatter.revisions), 2)