/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testlog.py

  • Committer: Martin Pool
  • Date: 2005-07-29 12:29:27 UTC
  • Revision ID: mbp@sourcefrog.net-20050729122927-d51c2cedc14dd5d5
doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import os
18
 
 
19
17
from bzrlib.selftest import BzrTestBase
20
 
from bzrlib.log import LogFormatter, show_log, LongLogFormatter
 
18
from bzrlib.log import LogFormatter, show_log
21
19
from bzrlib.branch import Branch
22
20
 
23
21
class _LogEntry(object):
40
38
        
41
39
        
42
40
    def show(self, revno, rev, delta):
43
 
        le = _LogEntry()
 
41
        le = _LogEntry
44
42
        le.revno = revno
45
43
        le.rev = rev
46
44
        le.delta = delta
48
46
 
49
47
 
50
48
class SimpleLogTest(BzrTestBase):
51
 
    def checkDelta(self, delta, **kw):
52
 
        """Check the filenames touched by a delta are as expected."""
53
 
        for n in 'added', 'removed', 'renamed', 'modified', 'unchanged':
54
 
            expected = kw.get(n, [])
55
 
 
56
 
            # tests are written with unix paths; fix them up for windows
57
 
            if os.sep != '/':
58
 
                expected = [x.replace('/', os.sep) for x in expected]
59
 
 
60
 
            # strip out only the path components
61
 
            got = [x[0] for x in getattr(delta, n)]
62
 
            self.assertEquals(expected, got)
63
 
 
64
 
    
65
49
    def runTest(self):
66
50
        eq = self.assertEquals
67
51
        ass = self.assert_
82
66
        eq(lf.logs[0].rev.message, 'empty commit')
83
67
        d = lf.logs[0].delta
84
68
        self.log('log delta: %r' % d)
85
 
        self.checkDelta(d)
86
 
 
87
 
 
88
 
        self.build_tree(['hello'])
89
 
        b.add('hello')
90
 
        b.commit('add one file')
91
 
        # log using regular thing
92
 
        show_log(b, LongLogFormatter(self.TEST_LOG))
93
 
 
94
 
        # get log as data structure
95
 
        lf = LogCatcher()
96
 
        show_log(b, lf, verbose=True)
97
 
        eq(len(lf.logs), 2)
98
 
        self.log('log entries:')
99
 
        for logentry in lf.logs:
100
 
            self.log('%4d %s' % (logentry.revno, logentry.rev.message))
101
 
        
102
 
        # first one is most recent
103
 
        logentry = lf.logs[0]
104
 
        eq(logentry.revno, 2)
105
 
        eq(logentry.rev.message, 'add one file')
106
 
        d = logentry.delta
107
 
        self.log('log 2 delta: %r' % d)
108
 
        # self.checkDelta(d, added=['hello'])
 
69
        ass(not d.added)
 
70
        ass(not d.removed)
 
71
        ass(not d.renamed)
 
72
        ass(not d.modified)
 
73
        ass(not d.unchanged)
 
74
 
109
75