~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_log.py

  • Committer: Robert Collins
  • Date: 2007-04-19 02:27:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2426.
  • Revision ID: robertc@robertcollins.net-20070419022744-pfdqz42kp1wizh43
``make docs`` now creates a man page at ``man1/bzr.1`` fixing bug 107388.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
22
22
 
23
23
import bzrlib
24
24
from bzrlib.tests.blackbox import ExternalBase
25
 
from bzrlib.tests import TestCaseInTempDir
 
25
from bzrlib.tests import TestCaseInTempDir, TestCaseWithTransport
26
26
 
27
27
 
28
28
class TestLog(ExternalBase):
89
89
        log = self.runbzr("log -r 1..3")[0]
90
90
        self.assertEquals(self.full_log, log)
91
91
 
 
92
    def test_log_revno_n_path(self):
 
93
        os.mkdir('branch1')
 
94
        os.chdir('branch1')
 
95
        self._prepare()
 
96
        os.chdir('..')
 
97
        os.mkdir('branch2')
 
98
        os.chdir('branch2')
 
99
        self._prepare()
 
100
        os.chdir('..')
 
101
        log = self.runbzr("log -r revno:2:branch1..revno:3:branch2",
 
102
                          retcode=3)[0]
 
103
        log = self.runbzr("log -r revno:1:branch2..revno:3:branch2")[0]
 
104
        self.assertEquals(self.full_log, log)
 
105
        log = self.runbzr("log -r revno:1:branch2")[0]
 
106
        self.assertTrue('revno: 1\n' in log)
 
107
        self.assertTrue('revno: 2\n' not in log)
 
108
        self.assertTrue('branch nick: branch2\n' in log)
 
109
        self.assertTrue('branch nick: branch1\n' not in log)
 
110
        
 
111
    def test_log_nonexistent_file(self):
 
112
        # files that don't exist in either the basis tree or working tree
 
113
        # should give an error
 
114
        wt = self.make_branch_and_tree('.')
 
115
        out, err = self.run_bzr('log', 'does-not-exist', retcode=3)
 
116
        self.assertContainsRe(
 
117
            err, 'Path does not have any revision history: does-not-exist')
92
118
 
93
119
class TestLogMerges(ExternalBase):
94
120
 
117
143
#message:
118
144
#  merge branch 1
119
145
#    ------------------------------------------------------------
 
146
#    revno: 1.1.2  
120
147
#    merged: foo@example.com-20060328113140-91f43cfb46dc2863
121
148
#    committer: Robert Collins <foo@example.com>
122
149
#    branch nick: child
124
151
#    message:
125
152
#      merge branch 2
126
153
#        ------------------------------------------------------------
 
154
#        revno: 1.1.1.1
127
155
#        merged: foo@example.com-20060328113140-1ba24f850a0ef573
128
156
#        committer: Robert Collins <foo@example.com>
129
157
#        branch nick: smallerchild
131
159
#        message:
132
160
#          branch 2
133
161
#    ------------------------------------------------------------
 
162
#    revno: 1.1.1
134
163
#    merged: foo@example.com-20060328113140-5749a4757a8ac792
135
164
#    committer: Robert Collins <foo@example.com>
136
165
#    branch nick: child
146
175
#  first post
147
176
#""", out)
148
177
        # but we dont have a nice pattern matcher hooked up yet, so:
149
 
        # we check for the indenting of the commit message:
 
178
        # we check for the indenting of the commit message and the 
 
179
        # revision numbers 
 
180
        self.assertTrue('revno: 2' in out)
150
181
        self.assertTrue('  merge branch 1' in out)
 
182
        self.assertTrue('    revno: 1.1.2' in out)
151
183
        self.assertTrue('      merge branch 2' in out)
 
184
        self.assertTrue('        revno: 1.1.1.1' in out)
152
185
        self.assertTrue('          branch 2' in out)
 
186
        self.assertTrue('    revno: 1.1.1' in out)
153
187
        self.assertTrue('      branch 1' in out)
 
188
        self.assertTrue('revno: 1' in out)
154
189
        self.assertTrue('  first post' in out)
155
190
        self.assertEqual('', err)
156
191
 
255
290
        # Make sure the cp1251 string is not found anywhere
256
291
        self.assertEquals(-1, stdout.find(test_in_cp1251))
257
292
 
 
293
 
 
294
class TestLogFile(TestCaseWithTransport):
 
295
 
 
296
    def test_log_local_branch_file(self):
 
297
        """We should be able to log files in local treeless branches"""
 
298
        tree = self.make_branch_and_tree('tree')
 
299
        self.build_tree(['tree/file'])
 
300
        tree.add('file')
 
301
        tree.commit('revision 1')
 
302
        tree.bzrdir.destroy_workingtree()
 
303
        self.run_bzr('log', 'tree/file')