view hgeditor @ 35058:a68c3420be41

rebase: exclude descendants of obsoletes w/o a successor in dest (issue5300) .. feature:: Let 'hg rebase' avoid content-divergence by skipping obsolete changesets (and their descendants) when they are present in the rebase set along with one of their successors but none of their successors is in destination. In the following example, when trying to rebase 3:: onto 2, the rebase will abort with "this rebase will cause divergence from: 4": o 7 f | | o 6 e | | | o 5 d' | | x | 4 d (rewritten as 5) |/ o 3 c | | o 2 x | | o | 1 b |/ o 0 a By excluding obsolete changesets without a successor in destination (4 in the example above) and their descendants, we make rebase work in this case, thus giving: o 11 e | o 10 d' | o 9 c | o 8 b | | o 7 f | | | | x 6 e (rewritten using rebase as 11) | | | | | x 5 d' (rewritten using rebase as 10) | | | | x | 4 d | |/ | x 3 c (rewritten using rebase as 9) | | o | 2 x | | | x 1 b (rewritten using rebase as 8) |/ o 0 a where branch 4:: is left behind while branch 5:: is rebased as expected. The rationale is that users may not be interested in rebasing orphan changesets when specifying a rebase set that include them but would still want "stable" ones to be rebased. Currently, the user is suggested to allow divergence (but probably does not want it) or they must specify a rebase set excluding problematic changesets (which might be a bit cumbersome). The approach proposed here corresponds to "Option 2" in https://www.mercurial-scm.org/wiki/CEDRebase. We extend _computeobsoletenotrebased() so that it also return a set of obsolete changesets in rebase set without a successor in destination but with at least one successor in rebase set. This 'obsoletewithoutsuccessorindestination' is then stored as an attribute of rebaseruntime and used in _performrebasesubset() to: * filter out descendants of these changesets from the revisions to rebase; * issue a message about these revisions being skipped. This only occurs if 'evolution.allowdivergence' option is off and 'rebaseskipobsolete' is on.
author Denis Laxalde <denis@laxalde.org>
date Tue, 14 Nov 2017 22:46:10 +0100
parents 1aee2ab0f902
children
line wrap: on
line source

#!/bin/sh
#
# This is an example of using HGEDITOR to create of diff to review the
# changes while committing.

# If you want to pass your favourite editor some other parameters
# only for Mercurial, modify this:
case "${EDITOR}" in
    "")
        EDITOR="vi"
        ;;
    emacs)
        EDITOR="$EDITOR -nw"
        ;;
    gvim|vim)
        EDITOR="$EDITOR -f -o"
        ;;
esac


HGTMP=""
cleanup_exit() {
    rm -rf "$HGTMP"
}

# Remove temporary files even if we get interrupted
trap "cleanup_exit" 0 # normal exit
trap "exit 255" HUP INT QUIT ABRT TERM

HGTMP=$(mktemp -d ${TMPDIR-/tmp}/hgeditor.XXXXXX)
[ x$HGTMP != x -a -d $HGTMP ] || {
  echo "Could not create temporary directory! Exiting." 1>&2
  exit 1
}

(
    grep '^HG: changed' "$1" | cut -b 13- | while read changed; do
        "$HG" diff "$changed" >> "$HGTMP/diff"
    done
)

cat "$1" > "$HGTMP/msg"

MD5=$(which md5sum 2>/dev/null) || \
    MD5=$(which md5 2>/dev/null)
[ -x "${MD5}" ] && CHECKSUM=`${MD5} "$HGTMP/msg"`
if [ -s "$HGTMP/diff" ]; then
    $EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $?
else
    $EDITOR "$HGTMP/msg" || exit $?
fi
[ -x "${MD5}" ] && (echo "$CHECKSUM" | ${MD5} -c >/dev/null 2>&1 && exit 13)

mv "$HGTMP/msg" "$1"

exit $?