~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-06 06:48:25 UTC
  • mfrom: (4070.8.6 debug-config)
  • Revision ID: pqm@pqm.ubuntu.com-20090306064825-kbpwggw21dygeix6
(mbp) debug_flags configuration option

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
18
18
from cStringIO import StringIO
198
198
        self.assertEqual('add file1 and file2', logentry.rev.message)
199
199
        self.checkDelta(logentry.delta, added=['file1', 'file2'])
200
200
 
 
201
    def test_merges_nonsupporting_formatter(self):
 
202
        """Tests that show_log will raise if the formatter doesn't
 
203
        support merge revisions."""
 
204
        wt = self.make_branch_and_memory_tree('.')
 
205
        wt.lock_write()
 
206
        self.addCleanup(wt.unlock)
 
207
        wt.add('')
 
208
        wt.commit('rev-1', rev_id='rev-1',
 
209
                  timestamp=1132586655, timezone=36000,
 
210
                  committer='Joe Foo <joe@foo.com>')
 
211
        wt.commit('rev-merged', rev_id='rev-2a',
 
212
                  timestamp=1132586700, timezone=36000,
 
213
                  committer='Joe Foo <joe@foo.com>')
 
214
        wt.set_parent_ids(['rev-1', 'rev-2a'])
 
215
        wt.branch.set_last_revision_info(1, 'rev-1')
 
216
        wt.commit('rev-2', rev_id='rev-2b',
 
217
                  timestamp=1132586800, timezone=36000,
 
218
                  committer='Joe Foo <joe@foo.com>')
 
219
        logfile = self.make_utf8_encoded_stringio()
 
220
        formatter = log.ShortLogFormatter(to_file=logfile)
 
221
        wtb = wt.branch
 
222
        lf = LogCatcher()
 
223
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
 
224
        rev = revspec.in_history(wtb)
 
225
        self.assertRaises(errors.BzrCommandError, log.show_log, wtb, lf,
 
226
                          start_revision=rev, end_revision=rev)
 
227
 
201
228
 
202
229
def make_commits_with_trailing_newlines(wt):
203
230
    """Helper method for LogFormatter tests"""
301
328
    1 Joe Foo\t2005-11-22
302
329
      rev-1
303
330
 
304
 
Use --levels 0 (or -n0) to see merged revisions.
305
331
""",
306
332
                             logfile.getvalue())
307
333
 
340
366
    2 Joe Foo\t2005-11-22 [merge]
341
367
      rev-2b
342
368
 
343
 
Use --levels 0 (or -n0) to see merged revisions.
344
369
""",
345
370
                             logfile.getvalue())
346
371
 
359
384
    1 Joe Foo\t2005-11-22
360
385
      rev-1
361
386
 
362
 
Use --levels 0 (or -n0) to see merged revisions.
363
387
""",
364
388
                             logfile.getvalue())
365
389
 
512
536
        wt.commit('merge branch 1')
513
537
        b = wt.branch
514
538
        sio = self.make_utf8_encoded_stringio()
515
 
        lf = log.LongLogFormatter(to_file=sio, levels=0)
 
539
        lf = log.LongLogFormatter(to_file=sio)
516
540
        log.show_log(b, lf, verbose=True)
517
541
        the_log = normalize_log(sio.getvalue())
518
542
        self.assertEqualDiff("""\
519
543
------------------------------------------------------------
520
 
revno: 2 [merge]
 
544
revno: 2
521
545
committer: Lorem Ipsum <test@example.com>
522
546
branch nick: parent
523
547
timestamp: Just now
524
548
message:
525
549
  merge branch 1
526
550
    ------------------------------------------------------------
527
 
    revno: 1.1.2 [merge]
 
551
    revno: 1.1.2
528
552
    committer: Lorem Ipsum <test@example.com>
529
553
    branch nick: child
530
554
    timestamp: Just now
569
593
        wt.commit('merge branch 1')
570
594
        b = wt.branch
571
595
        sio = self.make_utf8_encoded_stringio()
572
 
        lf = log.LongLogFormatter(to_file=sio, levels=0)
 
596
        lf = log.LongLogFormatter(to_file=sio)
573
597
        log.show_log(b, lf, verbose=True)
574
598
        the_log = normalize_log(sio.getvalue())
575
599
        self.assertEqualDiff("""\
576
600
------------------------------------------------------------
577
 
revno: 2 [merge]
 
601
revno: 2
578
602
committer: Lorem Ipsum <test@example.com>
579
603
branch nick: parent
580
604
timestamp: Just now
866
890
        the_log = normalize_log(sio.getvalue())
867
891
        self.assertEqualDiff("""\
868
892
------------------------------------------------------------
869
 
revno: 2 [merge]
 
893
revno: 2
870
894
committer: Lorem Ipsum <test@example.com>
871
895
branch nick: parent
872
896
timestamp: Just now
886
910
added:
887
911
  f1
888
912
  f2
889
 
------------------------------------------------------------
890
 
Use --levels 0 (or -n0) to see merged revisions.
891
913
""",
892
914
                             the_log)
893
915
 
1320
1342
                direction, # direction
1321
1343
                file_id, # specific_fileid
1322
1344
                True, # generate_merge_revisions
 
1345
                True, # allow_single_merge_revision
1323
1346
                )
1324
1347
            return revs
1325
1348
 
1476
1499
        self.assertAllRevisionsForFileID(tree, 'f1-id', ['XX', 'B', 'A'])
1477
1500
        self.assertAllRevisionsForFileID(tree, 'f2-id', ['D', 'C', 'A'])
1478
1501
 
1479
 
    def test_unknown_file_id(self):
1480
 
        tree = self.create_tree_with_single_merge()
1481
 
        self.assertAllRevisionsForFileID(tree, 'unknown', [])
1482
 
 
1483
 
    def test_empty_branch_unknown_file_id(self):
1484
 
        tree = self.make_branch_and_tree('tree')
1485
 
        self.assertAllRevisionsForFileID(tree, 'unknown', [])
1486
 
 
1487
1502
 
1488
1503
class TestShowChangedRevisions(tests.TestCaseWithTransport):
1489
1504