/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/delta.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

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