stabilize: improve unstable selection heuristic
Without argument, stabilize was picking the first in:
"unstable() and ((suspended() or obsancestors(::.))::)"
which usually returned the "oldest" unstable revision in parent
predecessors descendants. This revision is interesting because it
usually gives "soft" merges but rebasing it left the working directory
on a remote branch, which was very confusing.
The new heuristic picks an unstable changeset which can be rebased on
top of the parent revision, or on top of one of its descendants
(selected in revision order). This has the advantage of selecting a
revision which can be rebased on the current subtree, and leave the
working directory in a more convenient location.
#!/bin/sh
here=`python -c "import os; print os.path.realpath('$0')"`
repo_root=`dirname "$here"`
if !( hg --version -q | grep -qe 'version 2\.[1-9]' ); then
echo 'You need mercurial 2.1 or later' >&2
exit 2
fi
cat << EOF >&2
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX Add lines below to the [extensions] section of you hgrc XXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
EOF
cat << EOF | sed -e "s#XXXREPOPATHXXX#${repo_root}#"
[extensions]
### experimental extensions for history rewriting
# obsolete relation support (will move in core)
obsolete=XXXREPOPATHXXX/hgext/obsolete.py
# history rewriting UI
# needed by evolve
hgext.rebase=
evolve=XXXREPOPATHXXX/hgext/evolve.py
[alias]
### useful alias to check future amend result
# equivalent to the qdiff command for mq
# diff
pdiff=diff --rev .^
# status
pstatus=status --rev .^
# diff with the previous amend
odiff=diff --rev 'limit(obsparents(.),1)' --rev .
EOF
cat << EOF >&2
### check qsync-enable.sh if your need mq export too.
EOF