~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/delta.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-28 10:33:44 UTC
  • mfrom: (5171.2.3 401599-strict-warnings)
  • mto: This revision was merged to the branch mainline in revision 5191.
  • Revision ID: v.ladeuil+lp@free.fr-20100428103344-e32qf3cn1avdd2cb
Don't mention --no-strict when we just issue the warning about unclean trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from bzrlib import (
 
18
    errors,
18
19
    osutils,
19
20
    )
20
 
from bzrlib.trace import is_quiet
 
21
from bzrlib.inventory import InventoryEntry
 
22
from bzrlib.trace import mutter, is_quiet
 
23
from bzrlib.symbol_versioning import deprecated_function
21
24
 
22
25
 
23
26
class TreeDelta(object):
61
64
        self.modified = []
62
65
        self.unchanged = []
63
66
        self.unversioned = []
64
 
        self.missing = []
65
67
 
66
68
    def __eq__(self, other):
67
69
        if not isinstance(other, TreeDelta):
138
140
            else:
139
141
                delta.removed.append((path[0], file_id, kind[0]))
140
142
        elif fully_present[0] is False:
141
 
            delta.missing.append((path[1], file_id, kind[1]))
 
143
            continue
142
144
        elif name[0] != name[1] or parent_id[0] != parent_id[1]:
143
145
            # If the name changes, or the parent_id changes, we have a rename
144
146
            # (if we move a parent, that doesn't count as a rename for the
161
163
    delta.removed.sort()
162
164
    delta.added.sort()
163
165
    delta.renamed.sort()
164
 
    delta.missing.sort()
165
166
    # TODO: jam 20060529 These lists shouldn't need to be sorted
166
167
    #       since we added them in alphabetical order.
167
168
    delta.modified.sort()
174
175
    """Report changes between two trees"""
175
176
 
176
177
    def __init__(self, output=None, suppress_root_add=True,
177
 
                 output_file=None, unversioned_filter=None, view_info=None,
178
 
                 classify=True):
 
178
                 output_file=None, unversioned_filter=None, view_info=None):
179
179
        """Constructor
180
180
 
181
181
        :param output: a function with the signature of trace.note, i.e.
190
190
        :param view_info: A tuple of view_name,view_files if only
191
191
            items inside a view are to be reported on, or None for
192
192
            no view filtering.
193
 
        :param classify: Add special symbols to indicate file kind.
194
193
        """
195
194
        if output_file is not None:
196
195
            if output is not None:
206
205
                             'unchanged': ' ',
207
206
                             'created': 'N',
208
207
                             'modified': 'M',
209
 
                             'deleted': 'D',
210
 
                             'missing': '!',
211
 
                             }
 
208
                             'deleted': 'D'}
212
209
        self.versioned_map = {'added': '+', # versioned target
213
210
                              'unchanged': ' ', # versioned in both
214
211
                              'removed': '-', # versioned in source
215
212
                              'unversioned': '?', # versioned in neither
216
213
                              }
217
214
        self.unversioned_filter = unversioned_filter
218
 
        if classify:
219
 
            self.kind_marker = osutils.kind_marker
220
 
        else:
221
 
            self.kind_marker = lambda kind: ''
222
215
        if view_info is None:
223
216
            self.view_name = None
224
217
            self.view_files = []
273
266
            # if the file is not missing in the source, we show its kind
274
267
            # when we show two paths.
275
268
            if kind[0] is not None:
276
 
                old_path += self.kind_marker(kind[0])
 
269
                old_path += osutils.kind_marker(kind[0])
277
270
            old_path += " => "
278
271
        elif versioned == 'removed':
279
272
            # not present in target
288
281
            rename = self.versioned_map[versioned]
289
282
        # we show the old kind on the new path when the content is deleted.
290
283
        if modified == 'deleted':
291
 
            path += self.kind_marker(kind[0])
 
284
            path += osutils.kind_marker(kind[0])
292
285
        # otherwise we always show the current kind when there is one
293
286
        elif kind[1] is not None:
294
 
            path += self.kind_marker(kind[1])
 
287
            path += osutils.kind_marker(kind[1])
295
288
        if exe_change:
296
289
            exe = '*'
297
290
        else:
335
328
        else:
336
329
            if content_change:
337
330
                modified = "modified"
338
 
            elif kind[0] is None:
339
 
                modified = "missing"
340
331
            else:
341
332
                modified = "unchanged"
342
333
            if kind[1] == "file":
346
337
                        exe_change, kind)
347
338
 
348
339
def report_delta(to_file, delta, short_status=False, show_ids=False, 
349
 
         show_unchanged=False, indent='', filter=None, classify=True):
 
340
         show_unchanged=False, indent='', filter=None):
350
341
    """Output this delta in status-like form to to_file.
351
342
 
352
343
    :param to_file: A file-like object where the output is displayed.
364
355
 
365
356
    :param filter: A callable receiving a path and a file id and
366
357
        returning True if the path should be displayed.
367
 
 
368
 
    :param classify: Add special symbols to indicate file kind.
369
358
    """
370
359
 
371
360
    def decorate_path(path, kind, meta_modified=None):
372
 
        if not classify:
373
 
            return path
374
361
        if kind == 'directory':
375
362
            path += '/'
376
363
        elif kind == 'symlink':
433
420
 
434
421
    show_list(delta.removed, 'removed', 'D')
435
422
    show_list(delta.added, 'added', 'A')
436
 
    show_list(delta.missing, 'missing', '!')
437
423
    extra_modified = []
438
424
    # Reorder delta.renamed tuples so that all lists share the same
439
425
    # order for their 3 first fields and that they also begin like