15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from cStringIO import StringIO
20
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
19
from bzrlib.selftest import BzrTestBase
21
20
from bzrlib.log import LogFormatter, show_log, LongLogFormatter
22
21
from bzrlib.branch import Branch
23
from bzrlib.errors import InvalidRevisionNumber
25
23
class _LogEntry(object):
26
24
# should probably move into bzrlib.log?
49
47
self.logs.append(le)
52
class SimpleLogTest(TestCaseInTempDir):
50
class SimpleLogTest(BzrTestBase):
54
51
def checkDelta(self, delta, **kw):
55
52
"""Check the filenames touched by a delta are as expected."""
56
53
for n in 'added', 'removed', 'renamed', 'modified', 'unchanged':
64
61
got = [x[0] for x in getattr(delta, n)]
65
62
self.assertEquals(expected, got)
67
def test_cur_revno(self):
68
b = Branch('.', init=True)
71
b.commit('empty commit')
72
show_log(b, lf, verbose=True, start_revision=1, end_revision=1)
73
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
74
start_revision=2, end_revision=1)
75
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
76
start_revision=1, end_revision=2)
77
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
78
start_revision=0, end_revision=2)
79
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
80
start_revision=1, end_revision=0)
81
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
82
start_revision=-1, end_revision=1)
83
self.assertRaises(InvalidRevisionNumber, show_log, b, lf,
84
start_revision=1, end_revision=-1)
86
def test_simple_log(self):
87
66
eq = self.assertEquals
89
69
b = Branch('.', init=True)
108
88
self.build_tree(['hello'])
110
90
b.commit('add one file')
113
91
# log using regular thing
114
show_log(b, LongLogFormatter(lf))
116
for l in lf.readlines():
92
show_log(b, LongLogFormatter(self.TEST_LOG))
119
94
# get log as data structure