view hgeditor @ 48693:de3ac3d2c60b

stream-clone: allow to change persistent-nodemap format during stream clone Persistent nodemap affect the store format. However it is fairly isolated and fast to generate locally. So not making it a fixed part of the stream clone is useful. This allow clients without persistent-nodemap support (default for client without Rust enabled, or simply older client). So it make it possible to enable persistent nodemap on client, where it can provide a massive boost. without too much consequence. To do so, we stop using it in the advertisement requirements for streaming and let the client add/remove the necessary file depending of its configuration. We still send the files as it seems like a small save to not regenerate them. In addition, the way we match them will overlap with the changelog-v2/revlog-v2 so we can't simply skip the associated patterns. Differential Revision: https://phab.mercurial-scm.org/D12096
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 27 Jan 2022 22:24:11 +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 $?