2 # -*- coding:utf-8;mode:shell-script;mode:font-lock -*-
5 # Resolve Subversion conflicts using FileMerge.
7 # (FileMerge is a graphical diff tool in the Mac OS X Developer
10 # In your working copy, do (for example):
14 # FileMerge will open a window for each file that is in a conflict
15 # state, showing you diffs with the left/right arrows pointing to the
16 # side of each change that is selected. Diffs with gray outlines are
17 # automatically resolved. Diffs with red outlines are the conflicts.
18 # Find those and select which side you want, or pull up the split view
19 # at he bottom and edit the text to what it should be.
21 # Copyright (c) 2002 Wilfredo Sanchez Vega <wsanchez@wsanchez.net>.
22 # All rights reserved.
24 # Permission to use, copy, modify, and distribute this software for
25 # any purpose with or without fee is hereby granted, provided that the
26 # above copyright notice, this permission, and the following
27 # disclaimer notice appear in all copies.
29 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
30 # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
31 # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
32 # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
33 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
34 # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
35 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
36 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
48 program
=$
(basename "$0");
50 if [ $# != 0 ]; then echo "$@"; echo ""; fi;
52 echo "${program}: usage:";
53 echo " ${program} file1 [file2 ...]";
72 # If opendiff isn't installed, you can't launch FileMerge.
73 # If we're not in the OS X Terminal, we probably can't run FileMerge
75 if ! type opendiff
>& /dev
/null ||
[ "${TERM_PROGRAM:=}" != "Apple_Terminal" ]; then
85 n
=$
(ls -1 "${conflict}.merge-${which}.r"* 2>/dev
/null |
wc -l);
87 if [ "${n}" -eq 0 ]; then
88 echo "ERROR: No ${which} ancenstor found."
92 if [ "${n}" -gt 1 ]; then
93 echo "ERROR: Multible ${which} ancenstors found:"
94 ls -1 "${conflict}.merge-left.r"*
98 ls "${conflict}.merge-${which}.r"*
105 local revision
="$(svn info "${conflict}" | grep '^Revision: ' | sed 's|^Revision: ||')";
107 local left
="${conflict}.working";
108 local right
="$(find_ancestor "${conflict}" right)";
109 local ancestor
="$(find_ancestor "${conflict}" left )";
111 for file in "${left}" "${right}" "${ancestor}"; do
112 if [ ! -f "${file}" ]; then
113 echo "ERROR: Missing file: ${file}";
118 opendiff
"${left}" "${right}" -ancestor "${ancestor}" -merge "${conflict}";
122 for conflict
in $
(svn status . |
grep '^C' |
sed 's|^C......||'); do
123 resolve
"${conflict}";