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

  • Committer: Robert Collins
  • Date: 2006-03-03 02:09:49 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060303020949-0ddc6f33d0a43943
Smoke test for RevisionStore factories creating revision stores.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2006 Canonical Ltd.
 
1
# -*- coding: UTF-8 -*-
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
from bzrlib.delta import compare_trees
18
18
from bzrlib.errors import BzrError
19
 
import bzrlib.errors as errors
20
19
from bzrlib.symbol_versioning import *
21
20
from bzrlib.trace import mutter
22
21
 
236
235
    external_diff_options
237
236
        If set, use an external GNU diff and pass these options.
238
237
    """
 
238
 
239
239
    old_tree.lock_read()
240
240
    try:
241
241
        new_tree.lock_read()
251
251
def _show_diff_trees(old_tree, new_tree, to_file,
252
252
                     specific_files, external_diff_options):
253
253
 
254
 
    # TODO: Options to control putting on a prefix or suffix, perhaps
255
 
    # as a format string?
256
 
    old_label = 'a/'
257
 
    new_label = 'b/'
 
254
    # TODO: Options to control putting on a prefix or suffix, perhaps as a format string
 
255
    old_label = ''
 
256
    new_label = ''
258
257
 
259
258
    DEVNULL = '/dev/null'
260
259
    # Windows users, don't panic about this filename -- it is a
264
263
    # TODO: Generation of pseudo-diffs for added/deleted files could
265
264
    # be usefully made into a much faster special case.
266
265
 
267
 
    _raise_if_doubly_unversioned(specific_files, old_tree, new_tree)
268
 
 
269
266
    if external_diff_options:
270
267
        assert isinstance(external_diff_options, basestring)
271
268
        opts = external_diff_options.split()
274
271
    else:
275
272
        diff_file = internal_diff
276
273
    
 
274
 
277
275
    delta = compare_trees(old_tree, new_tree, want_unchanged=False,
278
276
                          specific_files=specific_files)
279
277
 
280
278
    has_changes = 0
281
279
    for path, file_id, kind in delta.removed:
282
280
        has_changes = 1
283
 
        print >>to_file, '=== removed %s %r' % (kind, old_label + path)
 
281
        print >>to_file, '=== removed %s %r' % (kind, path)
284
282
        old_tree.inventory[file_id].diff(diff_file, old_label + path, old_tree,
285
283
                                         DEVNULL, None, None, to_file)
286
284
    for path, file_id, kind in delta.added:
287
285
        has_changes = 1
288
 
        print >>to_file, '=== added %s %r' % (kind, new_label + path)
 
286
        print >>to_file, '=== added %s %r' % (kind, path)
289
287
        new_tree.inventory[file_id].diff(diff_file, new_label + path, new_tree,
290
288
                                         DEVNULL, None, None, to_file, 
291
289
                                         reverse=True)
294
292
        has_changes = 1
295
293
        prop_str = get_prop_change(meta_modified)
296
294
        print >>to_file, '=== renamed %s %r => %r%s' % (
297
 
                    kind, old_label + old_path, new_label + new_path, prop_str)
 
295
                          kind, old_path, new_path, prop_str)
298
296
        _maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
299
297
                                    new_label, new_path, new_tree,
300
298
                                    text_modified, kind, to_file, diff_file)
301
299
    for path, file_id, kind, text_modified, meta_modified in delta.modified:
302
300
        has_changes = 1
303
301
        prop_str = get_prop_change(meta_modified)
304
 
        print >>to_file, '=== modified %s %r%s' % (kind, old_label + path,
305
 
                    prop_str)
 
302
        print >>to_file, '=== modified %s %r%s' % (kind, path, prop_str)
306
303
        if text_modified:
307
304
            _maybe_diff_file_or_symlink(old_label, path, old_tree, file_id,
308
305
                                        new_label, path, new_tree,
309
306
                                        True, kind, to_file, diff_file)
310
 
 
311
307
    return has_changes
312
 
 
313
 
 
314
 
def _raise_if_doubly_unversioned(specific_files, old_tree, new_tree):
315
 
    """Complain if paths are not versioned in either tree."""
316
 
    if not specific_files:
317
 
        return
318
 
    old_unversioned = old_tree.filter_unversioned_files(specific_files)
319
 
    new_unversioned = new_tree.filter_unversioned_files(specific_files)
320
 
    unversioned = old_unversioned.intersection(new_unversioned)
321
 
    if unversioned:
322
 
        raise errors.PathsNotVersionedError(sorted(unversioned))
323
308
    
324
309
 
325
310
def get_prop_change(meta_modified):