/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/tests/blackbox/test_log.py

  • Committer: Ian Clatworthy
  • Date: 2009-03-25 05:33:40 UTC
  • mto: (4205.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 4206.
  • Revision ID: ian.clatworthy@canonical.com-20090325053340-86gbo7fh0dk09d32
get directory logging working again

Show diffs side-by-side

added added

removed removed

Lines of Context:
255
255
            ": nothing to repeat\n", err)
256
256
        self.assertEqual('', out)
257
257
 
 
258
 
258
259
class TestLogVerbose(TestCaseWithTransport):
259
260
 
260
261
    def setUp(self):
513
514
                  'YYYY-MM-DD HH:MM:SS +ZZZZ', string)
514
515
 
515
516
 
 
517
def subst_short_dates(string):
 
518
    """Replace date strings (without time or timezone) with constant values."""
 
519
    return re.sub(r'\d{4}-\d{2}-\d{2}',
 
520
                  'YYYY-MM-DD', string)
 
521
 
 
522
 
516
523
class TestLogDiff(TestCaseWithoutPropsHandler):
517
524
 
518
525
    def _prepare(self):
985
992
        self.assertNotContainsRe(log, '^3:', re.MULTILINE)
986
993
        self.assertNotContainsRe(log, '^3.1.1:', re.MULTILINE)
987
994
        self.assertNotContainsRe(log, '^4:', re.MULTILINE)
 
995
 
 
996
 
 
997
class TestLogMultiple(TestCaseWithTransport):
 
998
 
 
999
    def prepare_tree(self):
 
1000
        tree = self.make_branch_and_tree('parent')
 
1001
        self.build_tree([
 
1002
            'parent/file1',
 
1003
            'parent/file2',
 
1004
            'parent/dir1/',
 
1005
            'parent/dir1/file5',
 
1006
            'parent/dir1/dir2/',
 
1007
            'parent/dir1/dir2/file3',
 
1008
            'parent/file4'])
 
1009
        tree.add('file1')
 
1010
        tree.commit('add file1', committer='Lorem Ipsum <test@example.com>')
 
1011
        tree.add('file2')
 
1012
        tree.commit('add file2', committer='Lorem Ipsum <test@example.com>')
 
1013
        tree.add(['dir1', 'dir1/dir2', 'dir1/dir2/file3'])
 
1014
        tree.commit('add file3', committer='Lorem Ipsum <test@example.com>')
 
1015
        tree.add('file4')
 
1016
        tree.commit('add file4', committer='Lorem Ipsum <test@example.com>')
 
1017
        tree.add('dir1/file5')
 
1018
        tree.commit('add file5', committer='Lorem Ipsum <test@example.com>')
 
1019
        child_tree = tree.bzrdir.sprout('child').open_workingtree()
 
1020
        self.build_tree_contents([('child/file2', 'hello')])
 
1021
        child_tree.commit(message='branch 1',
 
1022
            committer='Lorem Ipsum <test@example.com>')
 
1023
        tree.merge_from_branch(child_tree.branch)
 
1024
        tree.commit(message='merge child branch',
 
1025
            committer='Lorem Ipsum <test@example.com>')
 
1026
        os.chdir('parent')
 
1027
 
 
1028
    def test_log_files(self):
 
1029
        """The log for multiple file should only list revs for those files"""
 
1030
        self.prepare_tree()
 
1031
        out, err = self.run_bzr('log --line -n0 file1 file2 dir1/dir2/file3')
 
1032
        self.assertEqual('', err)
 
1033
        log = normalize_log(out)
 
1034
        self.assertEqualDiff(subst_short_dates(log), """\
 
1035
6: Lorem Ipsum YYYY-MM-DD [merge] merge child branch
 
1036
  5.1.1: Lorem Ipsum YYYY-MM-DD branch 1
 
1037
3: Lorem Ipsum YYYY-MM-DD add file3
 
1038
2: Lorem Ipsum YYYY-MM-DD add file2
 
1039
1: Lorem Ipsum YYYY-MM-DD add file1
 
1040
""")
 
1041
 
 
1042
    def test_log_directory(self):
 
1043
        """The log for a directory should show all nested files."""
 
1044
        self.prepare_tree()
 
1045
        out, err = self.run_bzr('log --line -n0 dir1')
 
1046
        self.assertEqual('', err)
 
1047
        log = normalize_log(out)
 
1048
        self.assertEqualDiff(subst_short_dates(log), """\
 
1049
5: Lorem Ipsum YYYY-MM-DD add file5
 
1050
3: Lorem Ipsum YYYY-MM-DD add file3
 
1051
""")
 
1052
 
 
1053
    def test_log_nested_directory(self):
 
1054
        """The log for a directory should show all nested files."""
 
1055
        self.prepare_tree()
 
1056
        out, err = self.run_bzr('log --line -n0 dir1/dir2')
 
1057
        self.assertEqual('', err)
 
1058
        log = normalize_log(out)
 
1059
        self.assertEqualDiff(subst_short_dates(log), """\
 
1060
3: Lorem Ipsum YYYY-MM-DD add file3
 
1061
""")
 
1062
 
 
1063
    def test_log_in_nested_directory(self):
 
1064
        """The log for a directory should show all nested files."""
 
1065
        self.prepare_tree()
 
1066
        os.chdir("dir1")
 
1067
        out, err = self.run_bzr('log --line -n0 .')
 
1068
        self.assertEqual('', err)
 
1069
        log = normalize_log(out)
 
1070
        self.assertEqualDiff(subst_short_dates(log), """\
 
1071
5: Lorem Ipsum YYYY-MM-DD add file5
 
1072
3: Lorem Ipsum YYYY-MM-DD add file3
 
1073
""")
 
1074
 
 
1075
    def test_log_files_and_directories(self):
 
1076
        """Logging files and directories together should be fine."""
 
1077
        self.prepare_tree()
 
1078
        out, err = self.run_bzr('log --line -n0 file4 dir1/dir2')
 
1079
        self.assertEqual('', err)
 
1080
        log = normalize_log(out)
 
1081
        self.assertEqualDiff(subst_short_dates(log), """\
 
1082
4: Lorem Ipsum YYYY-MM-DD add file4
 
1083
3: Lorem Ipsum YYYY-MM-DD add file3
 
1084
""")
 
1085
 
 
1086
    def test_log_files_and_dirs_in_nested_directory(self):
 
1087
        """The log for a directory should show all nested files."""
 
1088
        self.prepare_tree()
 
1089
        os.chdir("dir1")
 
1090
        out, err = self.run_bzr('log --line -n0 dir2 file5')
 
1091
        self.assertEqual('', err)
 
1092
        log = normalize_log(out)
 
1093
        self.assertEqualDiff(subst_short_dates(log), """\
 
1094
5: Lorem Ipsum YYYY-MM-DD add file5
 
1095
3: Lorem Ipsum YYYY-MM-DD add file3
 
1096
""")