~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/patch.py

  • Committer: Robey Pointer
  • Date: 2006-07-01 19:03:33 UTC
  • mfrom: (1829 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1830.
  • Revision ID: robey@lag.net-20060701190333-f58465aec4bd3412
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import errno
1
2
import os
2
3
from subprocess import Popen, PIPE
 
4
 
 
5
from bzrlib.errors import NoDiff3
 
6
from bzrlib.textfile import check_text_path
3
7
"""
4
8
Diff and patch functionality
5
9
"""
48
52
def diff3(out_file, mine_path, older_path, yours_path):
49
53
    def add_label(args, label):
50
54
        args.extend(("-L", label))
 
55
    check_text_path(mine_path)
 
56
    check_text_path(older_path)
 
57
    check_text_path(yours_path)
51
58
    args = ['diff3', "-E", "--merge"]
52
59
    add_label(args, "TREE")
53
60
    add_label(args, "ANCESTOR")
54
61
    add_label(args, "MERGE-SOURCE")
55
62
    args.extend((mine_path, older_path, yours_path))
56
 
    output, stderr, status = write_to_cmd(args)
 
63
    try:
 
64
        output, stderr, status = write_to_cmd(args)
 
65
    except OSError, e:
 
66
        if e.errno == errno.ENOENT:
 
67
            raise NoDiff3
 
68
        else:
 
69
            raise
57
70
    if status not in (0, 1):
58
71
        raise Exception(stderr)
59
72
    file(out_file, "wb").write(output)