~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_delta.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-02-21 07:21:10 UTC
  • mfrom: (4029.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090221072110-uf8tjt38l6r3vo6o
Filtered views (Ian Clatworthy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
                     versioned_change='unchanged', renamed=False,
42
42
                     modified='unchanged', exe_change=False,
43
43
                     kind=('file', 'file'), old_path=None,
44
 
                     unversioned_filter=None):
 
44
                     unversioned_filter=None, view_info=None):
 
45
        if expected is None:
 
46
            expected_lines = None
 
47
        else:
 
48
            expected_lines = [expected]
 
49
        self.assertReportLines(expected_lines, file_id, path,
 
50
                     versioned_change, renamed,
 
51
                     modified, exe_change,
 
52
                     kind, old_path,
 
53
                     unversioned_filter, view_info)
 
54
 
 
55
    def assertReportLines(self, expected_lines, file_id='fid', path='path',
 
56
                     versioned_change='unchanged', renamed=False,
 
57
                     modified='unchanged', exe_change=False,
 
58
                     kind=('file', 'file'), old_path=None,
 
59
                     unversioned_filter=None, view_info=None):
45
60
        result = []
46
61
        def result_line(format, *args):
47
62
            result.append(format % args)
48
63
        reporter = _mod_delta._ChangeReporter(result_line,
49
 
            unversioned_filter=unversioned_filter)
 
64
            unversioned_filter=unversioned_filter, view_info=view_info)
50
65
        reporter.report(file_id, (old_path, path), versioned_change, renamed,
51
66
            modified, exe_change, kind)
52
 
        if expected is not None:
53
 
            self.assertEqualDiff(expected, result[0])
 
67
        if expected_lines is not None:
 
68
            for i in range(len(expected_lines)):
 
69
                self.assertEqualDiff(expected_lines[i], result[i])
54
70
        else:
55
71
            self.assertEqual([], result)
56
72
 
107
123
            renamed=False, modified='created', exe_change=False,
108
124
            kind=(None, 'file'), unversioned_filter=lambda x:True)
109
125
 
 
126
    def test_view_filtering(self):
 
127
        # If a file in within the view, it should appear in the output
 
128
        expected_lines = [
 
129
            "Operating on whole tree but only reporting on 'my' view.",
 
130
            " M  path"]
 
131
        self.assertReportLines(expected_lines, modified='modified',
 
132
            view_info=('my',['path']))
 
133
        # If a file in outside the view, it should not appear in the output
 
134
        expected_lines = [
 
135
            "Operating on whole tree but only reporting on 'my' view."]
 
136
        self.assertReportLines(expected_lines, modified='modified',
 
137
            path="foo", view_info=('my',['path']))
 
138
 
110
139
    def assertChangesEqual(self,
111
140
                           file_id='fid',
112
141
                           paths=('path', 'path'),