15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from cStringIO import StringIO
19
from bzrlib.selftest import BzrTestBase
20
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
20
21
from bzrlib.log import LogFormatter, show_log, LongLogFormatter
21
22
from bzrlib.branch import Branch
23
from bzrlib.errors import InvalidRevisionNumber
23
25
class _LogEntry(object):
24
26
# should probably move into bzrlib.log?
47
49
self.logs.append(le)
50
class SimpleLogTest(BzrTestBase):
52
class SimpleLogTest(TestCaseInTempDir):
52
54
def checkDelta(self, delta, **kw):
53
55
"""Check the filenames touched by a delta are as expected."""
62
64
got = [x[0] for x in getattr(delta, n)]
63
65
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)
65
86
def test_simple_log(self):
66
87
eq = self.assertEquals
69
89
b = Branch('.', init=True)
88
108
self.build_tree(['hello'])
90
110
b.commit('add one file')
91
113
# log using regular thing
92
show_log(b, LongLogFormatter(self.TEST_LOG))
114
show_log(b, LongLogFormatter(lf))
116
for l in lf.readlines():
94
119
# get log as data structure