~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/patch.py

  • Committer: Robert Collins
  • Date: 2005-10-18 05:26:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1463.
  • Revision ID: robertc@robertcollins.net-20051018052622-653d638c9e26fde4
fix broken tests

Show diffs side-by-side

added added

removed removed

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