annotate hgmerge @ 266:4af7677de4a9

Fix argument processing for patch and rawcommit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fix argument processing for patch and rawcommit manifest hash: fc76fcd22ca69185bbec1855f72dda5b692e03f3 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCpVNMywK+sNU5EO8RAn2nAJ4gBbdn8K6xN55Igh6J2ZJEMgRGBACgr0Xb KkjbnOrNL5uQmBHx59C7HdY= =qsQi -----END PGP SIGNATURE-----
author mpm@selenic.com
date Mon, 06 Jun 2005 23:57:00 -0800
parents a2edb4481f19
children a69c3b2957d1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
240
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
1 #!/bin/bash
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
2 #
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
3 # hgmerge - default merge helper for Mercurial
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
4 #
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
5 # This tries to find a way to do three-way merge on the current system.
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
6 # The result ought to end up in $1.
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
7
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
8 set -e # bail out quickly on failure
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
9
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
10 LOCAL=$1
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
11 BASE=$2
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
12 OTHER=$3
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
13
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
14 # Back up our file
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
15 cp $LOCAL $LOCAL.orig
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
16
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
17 # Attempt to do a non-interactive merge
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
18 if which merge > /dev/null ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
19 if merge $LOCAL $BASE $OTHER 2> /dev/null; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
20 # success!
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
21 exit 0
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
22 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
23 cp $LOCAL.orig $LOCAL
242
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
24 elif which diff3 > /dev/null ; then
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
25 if diff3 -m $LOCAL.orig $BASE $OTHER > $LOCAL ; then
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
26 # success
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
27 exit 0
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
28 fi
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
29 cp $LOCAL.orig $LOCAL
240
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
30 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
31
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
32 # try using kdiff3, which is fairly nice
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
33 if which kdiff3 > /dev/null ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
34 if kdiff3 --auto $BASE $LOCAL $OTHER -o $LOCAL ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
35 exit 0
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
36 else
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
37 exit 1
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
38 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
39 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
40
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
41 # try using tkdiff, which is a bit less sophisticated
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
42 if which tkdiff > /dev/null ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
43 if tkdiff $LOCAL $OTHER -a $BASE -o $LOCAL ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
44 exit 0
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
45 else
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
46 exit 1
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
47 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
48 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
49
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
50 # Attempt to do a merge with $EDITOR
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
51 if which merge > /dev/null ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
52 echo "conflicts detected in $LOCAL"
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
53 merge $LOCAL $BASE $OTHER 2>/dev/null || $EDITOR $LOCAL
242
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
54 exit 0
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
55 fi
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
56
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
57 if which diff3 > /dev/null ; then
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
58 echo "conflicts detected in $LOCAL"
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
59 diff3 -m $LOCAL.orig $BASE $OTHER > $LOCAL || $EDITOR $LOCAL
a2edb4481f19 hgmerge: use diff3 if available
mpm@selenic.com
parents: 240
diff changeset
60 exit 0
240
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
61 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
62
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
63 # attempt to manually merge with diff and patch
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
64 if which diff > /dev/null ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
65 if which patch > /dev/null ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
66 T=`mktemp`
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
67 diff -u $BASE $OTHER > $T
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
68 if patch $LOCAL < $T ; then
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
69 exit 0
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
70 else
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
71 $EDITOR $LOCAL $LOCAL.rej
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
72 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
73 rm $T
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
74 exit 1
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
75 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
76 fi
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
77
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
78 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"
737c66b68290 Replace tkmerge with hgmerge
mpm@selenic.com
parents:
diff changeset
79 exit 1