~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

  • Committer: Vincent Ladeuil
  • Date: 2008-12-10 08:44:03 UTC
  • mto: (3941.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3942.
  • Revision ID: v.ladeuil+lp@free.fr-20081210084403-89803az7m7rysrsy
Add a 'path_filter' parameter to delta.show().

* bzrlib/tests/test_delta.py:
(TestDeltaShow): Tests for delta.show() and the new 'path_filter'
parameter.

* bzrlib/delta.py:
(TreeDelta.show.show_list): Display header only once, before first
file is displayed. Add a path_filter parameter. Add doc_string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
 
110
110
 
111
111
    def show(self, to_file, show_ids=False, show_unchanged=False,
112
 
             short_status=False, indent=''):
113
 
        """output this delta in status-like form to to_file."""
 
112
             short_status=False, indent='',
 
113
             path_filter=None):
 
114
        """Output this delta in status-like form to to_file.
 
115
 
 
116
        :param to_file: A file-like object where the output is displayed.
 
117
 
 
118
        :param show_ids: Output the file ids if True.
 
119
 
 
120
        :param show_unchanged: Output the unchanged files if True.
 
121
 
 
122
        :param short_status: Single-line status if True.
 
123
 
 
124
        :param indent: Added at the beginning of all output lines (for merged
 
125
            revisions).
 
126
 
 
127
        :param path_filter: A callable recieving a path and returning True if
 
128
            the path should be displayed.
 
129
        """
114
130
 
115
131
        def decorate_path(path, kind, meta_modified=None):
116
132
            if kind == 'directory':
146
162
                      default_format='%s', with_file_id_format='%-30s',
147
163
                      show_more=None):
148
164
            if files:
 
165
                header_shown = False
149
166
                if short_status:
150
167
                    prefix = short_status_letter
151
168
                else:
152
 
                    to_file.write(indent + long_status_name + ':\n')
153
169
                    prefix = ''
154
170
                prefix = indent + prefix + '  '
155
171
 
156
172
                for item in files:
157
173
                    path, file_id, kind = item[:3]
 
174
                    if (path_filter is not None and not path_filter(path)):
 
175
                        continue
 
176
                    if not header_shown and not short_status:
 
177
                        to_file.write(indent + long_status_name + ':\n')
 
178
                        header_shown = True
158
179
                    meta_modified = None
159
180
                    if len(item) == 5:
160
181
                        meta_modified = item[4]