~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

(jameinel) Make kind markers optional for bzr status. (Martin von Gagern)

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
    """Report changes between two trees"""
175
175
 
176
176
    def __init__(self, output=None, suppress_root_add=True,
177
 
                 output_file=None, unversioned_filter=None, view_info=None):
 
177
                 output_file=None, unversioned_filter=None, view_info=None,
 
178
                 classify=True):
178
179
        """Constructor
179
180
 
180
181
        :param output: a function with the signature of trace.note, i.e.
189
190
        :param view_info: A tuple of view_name,view_files if only
190
191
            items inside a view are to be reported on, or None for
191
192
            no view filtering.
 
193
        :param classify: Add special symbols to indicate file kind.
192
194
        """
193
195
        if output_file is not None:
194
196
            if output is not None:
213
215
                              'unversioned': '?', # versioned in neither
214
216
                              }
215
217
        self.unversioned_filter = unversioned_filter
 
218
        if classify:
 
219
            self.kind_marker = osutils.kind_marker
 
220
        else:
 
221
            self.kind_marker = lambda kind: ''
216
222
        if view_info is None:
217
223
            self.view_name = None
218
224
            self.view_files = []
267
273
            # if the file is not missing in the source, we show its kind
268
274
            # when we show two paths.
269
275
            if kind[0] is not None:
270
 
                old_path += osutils.kind_marker(kind[0])
 
276
                old_path += self.kind_marker(kind[0])
271
277
            old_path += " => "
272
278
        elif versioned == 'removed':
273
279
            # not present in target
282
288
            rename = self.versioned_map[versioned]
283
289
        # we show the old kind on the new path when the content is deleted.
284
290
        if modified == 'deleted':
285
 
            path += osutils.kind_marker(kind[0])
 
291
            path += self.kind_marker(kind[0])
286
292
        # otherwise we always show the current kind when there is one
287
293
        elif kind[1] is not None:
288
 
            path += osutils.kind_marker(kind[1])
 
294
            path += self.kind_marker(kind[1])
289
295
        if exe_change:
290
296
            exe = '*'
291
297
        else:
340
346
                        exe_change, kind)
341
347
 
342
348
def report_delta(to_file, delta, short_status=False, show_ids=False, 
343
 
         show_unchanged=False, indent='', filter=None):
 
349
         show_unchanged=False, indent='', filter=None, classify=True):
344
350
    """Output this delta in status-like form to to_file.
345
351
 
346
352
    :param to_file: A file-like object where the output is displayed.
358
364
 
359
365
    :param filter: A callable receiving a path and a file id and
360
366
        returning True if the path should be displayed.
 
367
 
 
368
    :param classify: Add special symbols to indicate file kind.
361
369
    """
362
370
 
363
371
    def decorate_path(path, kind, meta_modified=None):
 
372
        if not classify:
 
373
            return path
364
374
        if kind == 'directory':
365
375
            path += '/'
366
376
        elif kind == 'symlink':