contrib/check-compat-strings.sh
author Martin von Zweigbergk <martinvonz@google.com>
Mon, 09 Dec 2019 11:09:11 -0800
changeset 5343 ebfd0d875600
parent 5192 f5b366a31740
permissions -rwxr-xr-x
evolve: handle relocation during divergence resolution producing no changes When resolving divergence and the two divergent commits have different parents, we start by rebasing one of them to have the same parent as the other. That step can result in no changes to commit. When it does, we would crash with a TypeError before this patch. This patch fixes it by instead creating an empty commit in that scenario. The existing code then continues to attempt to merge it, which produces no changes, and no commit is created on top. The other side of the divergence is marked as successor as usual, so orphans from the side that became empty will be evolved to the right place (see test).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5192
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     1
#!/usr/bin/env bash
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     2
set -euo pipefail
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     3
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     4
unset GREP_OPTIONS
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     5
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     6
# This script finds compatibility-related comments with a node hash specified
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     7
# in all files in a given directory (. by default) and looks up the hash in a
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     8
# repo (~/hg by default) to determine if each of the comments is correct and,
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
     9
# if not, it suggests the correct release. This can prevent accidentally
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    10
# removing a piece of code that was misattributed to a different (earlier)
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    11
# release of core hg.
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    12
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    13
# Usage: $0 WDIR HGREPO where WDIR is usually evolve/hgext3rd/ and HGREPO is
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    14
# the place with core Mercurial repo (not just checkout). Said repo has to be
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    15
# sufficiently up-to-date, otherwise this script may not work correctly.
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    16
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    17
workdir=${1:-'.'}
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    18
hgdir=${2:-~/hg}
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    19
grep -Ern 'hg <= [0-9.]+ \([0-9a-f+]+\)' "$workdir" | while read -r line; do
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    20
    bashre='hg <= ([0-9.]+) \(([0-9a-f+]+)\)'
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    21
    if [[ $line =~ $bashre ]]; then
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    22
        expected=${BASH_REMATCH[1]}
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    23
        revset=${BASH_REMATCH[2]}
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    24
        tagrevset="max(tag('re:^[0-9]\\.[0-9]$') - ($revset)::)"
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    25
        lastrel=$(HGPLAIN=1 hg --cwd "$hgdir" log -r "$tagrevset" -T '{tags}')
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    26
        if [[ "$lastrel" != "$expected" ]]; then
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    27
            echo "$line"
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    28
            echo "actual last major release without $revset is $lastrel"
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    29
            echo
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    30
        fi
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    31
    fi
f5b366a31740 contrib: add a script to check release in compat comments that have node hash
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
    32
done