~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import difflib
18
18
import os
41
41
""")
42
42
 
43
43
from bzrlib.symbol_versioning import (
44
 
        deprecated_function,
45
 
        one_three
46
 
        )
 
44
    deprecated_function,
 
45
    )
47
46
from bzrlib.trace import mutter, note, warning
48
47
 
49
48
 
79
78
    # both sequences are empty.
80
79
    if not oldlines and not newlines:
81
80
        return
82
 
    
 
81
 
83
82
    if allow_binary is False:
84
83
        textfile.check_text_lines(oldlines)
85
84
        textfile.check_text_lines(newlines)
200
199
            break
201
200
        else:
202
201
            diffcmd.append('-u')
203
 
                  
 
202
 
204
203
        if diff_opts:
205
204
            diffcmd.extend(diff_opts)
206
205
 
207
206
        pipe = _spawn_external_diff(diffcmd, capture_errors=True)
208
207
        out,err = pipe.communicate()
209
208
        rc = pipe.returncode
210
 
        
 
209
 
211
210
        # internal_diff() adds a trailing newline, add one here for consistency
212
211
        out += '\n'
213
212
        if rc == 2:
248
247
                msg = 'signal %d' % (-rc)
249
248
            else:
250
249
                msg = 'exit code %d' % rc
251
 
                
252
 
            raise errors.BzrError('external diff failed with %s; command: %r' 
 
250
 
 
251
            raise errors.BzrError('external diff failed with %s; command: %r'
253
252
                                  % (rc, diffcmd))
254
253
 
255
254
 
334
333
        bzrdir.BzrDir.open_containing_tree_or_branch(old_url)
335
334
    if consider_relpath and relpath != '':
336
335
        if working_tree is not None and apply_view:
337
 
            _check_path_in_view(working_tree, relpath)
 
336
            views.check_path_in_view(working_tree, relpath)
338
337
        specific_files.append(relpath)
339
338
    old_tree = _get_tree_to_diff(old_revision_spec, working_tree, branch)
340
339
 
346
345
            bzrdir.BzrDir.open_containing_tree_or_branch(new_url)
347
346
        if consider_relpath and relpath != '':
348
347
            if working_tree is not None and apply_view:
349
 
                _check_path_in_view(working_tree, relpath)
 
348
                views.check_path_in_view(working_tree, relpath)
350
349
            specific_files.append(relpath)
351
350
    new_tree = _get_tree_to_diff(new_revision_spec, working_tree, branch,
352
351
        basis_is_default=working_tree is None)
368
367
            if view_files:
369
368
                specific_files = view_files
370
369
                view_str = views.view_display_str(view_files)
371
 
                note("*** ignoring files outside view: %s" % view_str)
 
370
                note("*** Ignoring files outside view. View is %s" % view_str)
372
371
 
373
372
    # Get extra trees that ought to be searched for file-ids
374
373
    extra_trees = None
376
375
        extra_trees = (working_tree,)
377
376
    return old_tree, new_tree, specific_files, extra_trees
378
377
 
379
 
 
380
 
def _check_path_in_view(tree, relpath):
381
 
    """If a working tree has a view enabled, check the path is within it."""
382
 
    if tree.supports_views():
383
 
        view_files = tree.views.lookup_view()
384
 
        if  view_files and not osutils.is_inside_any(view_files, relpath):
385
 
            raise errors.FileOutsideView(relpath, view_files)
386
 
 
387
 
 
388
378
def _get_tree_to_diff(spec, tree=None, branch=None, basis_is_default=True):
389
379
    if branch is None and tree is not None:
390
380
        branch = tree.branch
450
440
    return timestamp.format_patch_date(mtime)
451
441
 
452
442
 
453
 
@deprecated_function(one_three)
454
 
def get_prop_change(meta_modified):
455
 
    if meta_modified:
456
 
        return " (properties changed)"
457
 
    else:
458
 
        return  ""
459
 
 
460
443
def get_executable_change(old_is_x, new_is_x):
461
444
    descr = { True:"+x", False:"-x", None:"??" }
462
445
    if old_is_x != new_is_x: