contrib/merge-test-compat.sh
author Manuel Jacob <me@manueljacob.de>
Wed, 11 Mar 2020 16:04:06 +0100
branchstable
changeset 5206 dc3571a37b56
parent 5081 17fac26833da
permissions -rwxr-xr-x
evolve: support ancestor of orphan split with unrelated changeset in between This is done by searching for roots and heads within the range delimited on both sides by the target revs instead of just within the target revs. Example: o 5 | o 4 | o 3 | | * 2 | | | x 1 |/ o 0 1 is obsoleted by 3 and 5. We are considering the case when 2 gets evolved. Before the change, both roots and heads were [3, 5]. The user was offered a choice between 3 and 5 as the destination. After the change, roots are [3] and heads are [5]. 5 is chosen as the destination.

#!/bin/bash
set -euox pipefail

unset GREP_OPTIONS

compatbranches=$(hg branches --quiet | grep 'mercurial-' | grep -v ':' | sort -n --reverse)
prev='stable'
topic=${1:-'test-compat'}
for branch in $compatbranches; do
    # Logic in the revsets below:
    # 1. There is target topic on stable or compatibility branch: merge all
    # those commits, they are related to our work and need to pass tests on all
    # compatibility branches.
    # 2. There is no target topic: avoid any commits that have topic set, they
    # are definitely unrelated to what we're doing.
    # In other words, if you want to test certain commits, assign them all to
    # one topic and provide that topic as the first argument to this script.
    uptarget="first(max(branch('$branch') and topic('$topic')) or max(branch('$branch') and not topic()))"
    hg up -r "$uptarget"
    hg topic "$topic"
    mergetarget="first(max(branch('$prev') and topic('$topic')) or max(branch('$prev') and not topic()))"
    hg merge -r "$mergetarget"
    hg commit -m "test-compat: merge $prev into $branch"
    prev=$branch
done