Mercurial > hg > mercurial-crew-with-dirclash
annotate hgmerge @ 442:3e2aee6c5500
rawcommit dirstate tweak
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
rawcommit dirstate tweak
Before this patch, rawcommit can mess up the dirstate unless it is
committing against the current parent.
This patch changes rawcommit, such that when adding a child to some
node other than the current parent, rawcommit does not attempt update
the current dirstate.
This seems easily debatable; it creates an asymmetric behavior for
rawcommit. It means that when doing a rawcommit against the current
parent, there's effectively an implied "hg update" to the newly
created node. When doing a rawcommit against any other node, no such
"hg update" occurs.
The other obvious alternates would be:
1) rawcommit never update the dirstate
2) rawcommit always does an "hg update"...
This patch also includes a test for various uses of rawcommit...
Michael Fetterman
manifest hash: 428517d82a02501f14b0d8fac064411980780e91
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCuymPywK+sNU5EO8RAvdvAKCxW1QZtyOviNfuwO592IaKApwvEACfdrYD
83m/o8oJvRKu3yGvNGHtwfk=
=KbmU
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Thu, 23 Jun 2005 13:28:47 -0800 |
parents | f06a4a3b86a7 |
children | 3d4d5f2aba9a 4fc63e22b1fe |
rev | line source |
---|---|
240 | 1 #!/bin/bash |
2 # | |
3 # hgmerge - default merge helper for Mercurial | |
4 # | |
5 # This tries to find a way to do three-way merge on the current system. | |
6 # The result ought to end up in $1. | |
7 | |
8 set -e # bail out quickly on failure | |
9 | |
10 LOCAL=$1 | |
11 BASE=$2 | |
12 OTHER=$3 | |
13 | |
304
38fb7d23b78d
Use vi if $EDITOR is unset.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
303
diff
changeset
|
14 EDITOR="${EDITOR:-vi}" |
38fb7d23b78d
Use vi if $EDITOR is unset.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
303
diff
changeset
|
15 |
240 | 16 # Back up our file |
17 cp $LOCAL $LOCAL.orig | |
18 | |
19 # Attempt to do a non-interactive merge | |
20 if which merge > /dev/null ; then | |
21 if merge $LOCAL $BASE $OTHER 2> /dev/null; then | |
22 # success! | |
23 exit 0 | |
24 fi | |
25 cp $LOCAL.orig $LOCAL | |
242 | 26 elif which diff3 > /dev/null ; then |
27 if diff3 -m $LOCAL.orig $BASE $OTHER > $LOCAL ; then | |
28 # success | |
29 exit 0 | |
30 fi | |
31 cp $LOCAL.orig $LOCAL | |
240 | 32 fi |
33 | |
303
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
34 if [ -n "$DISPLAY" ]; then |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
35 # try using kdiff3, which is fairly nice |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
36 if which kdiff3 > /dev/null ; then |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
37 if kdiff3 --auto $BASE $LOCAL $OTHER -o $LOCAL ; then |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
38 exit 0 |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
39 else |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
40 exit 1 |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
41 fi |
240 | 42 fi |
43 | |
303
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
44 # try using tkdiff, which is a bit less sophisticated |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
45 if which tkdiff > /dev/null ; then |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
46 if tkdiff $LOCAL $OTHER -a $BASE -o $LOCAL ; then |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
47 exit 0 |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
48 else |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
49 exit 1 |
15a9e55e7ea5
Check if $DISPLAY is set before using tkdiff or kdiff3.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
280
diff
changeset
|
50 fi |
240 | 51 fi |
52 fi | |
53 | |
54 # Attempt to do a merge with $EDITOR | |
55 if which merge > /dev/null ; then | |
56 echo "conflicts detected in $LOCAL" | |
57 merge $LOCAL $BASE $OTHER 2>/dev/null || $EDITOR $LOCAL | |
242 | 58 exit 0 |
59 fi | |
60 | |
61 if which diff3 > /dev/null ; then | |
62 echo "conflicts detected in $LOCAL" | |
63 diff3 -m $LOCAL.orig $BASE $OTHER > $LOCAL || $EDITOR $LOCAL | |
64 exit 0 | |
240 | 65 fi |
66 | |
67 # attempt to manually merge with diff and patch | |
68 if which diff > /dev/null ; then | |
69 if which patch > /dev/null ; then | |
70 T=`mktemp` | |
71 diff -u $BASE $OTHER > $T | |
72 if patch $LOCAL < $T ; then | |
73 exit 0 | |
74 else | |
75 $EDITOR $LOCAL $LOCAL.rej | |
76 fi | |
77 rm $T | |
78 exit 1 | |
79 fi | |
80 fi | |
81 | |
82 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!" | |
83 exit 1 |