Mercurial > evolve
comparison contrib/check-compat-strings.sh @ 5192:f5b366a31740
contrib: add a script to check release in compat comments that have node hash
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 10 Mar 2020 19:04:33 +0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5191:dadc642e78d2 | 5192:f5b366a31740 |
---|---|
1 #!/usr/bin/env bash | |
2 set -euo pipefail | |
3 | |
4 unset GREP_OPTIONS | |
5 | |
6 # This script finds compatibility-related comments with a node hash specified | |
7 # in all files in a given directory (. by default) and looks up the hash in a | |
8 # repo (~/hg by default) to determine if each of the comments is correct and, | |
9 # if not, it suggests the correct release. This can prevent accidentally | |
10 # removing a piece of code that was misattributed to a different (earlier) | |
11 # release of core hg. | |
12 | |
13 # Usage: $0 WDIR HGREPO where WDIR is usually evolve/hgext3rd/ and HGREPO is | |
14 # the place with core Mercurial repo (not just checkout). Said repo has to be | |
15 # sufficiently up-to-date, otherwise this script may not work correctly. | |
16 | |
17 workdir=${1:-'.'} | |
18 hgdir=${2:-~/hg} | |
19 grep -Ern 'hg <= [0-9.]+ \([0-9a-f+]+\)' "$workdir" | while read -r line; do | |
20 bashre='hg <= ([0-9.]+) \(([0-9a-f+]+)\)' | |
21 if [[ $line =~ $bashre ]]; then | |
22 expected=${BASH_REMATCH[1]} | |
23 revset=${BASH_REMATCH[2]} | |
24 tagrevset="max(tag('re:^[0-9]\\.[0-9]$') - ($revset)::)" | |
25 lastrel=$(HGPLAIN=1 hg --cwd "$hgdir" log -r "$tagrevset" -T '{tags}') | |
26 if [[ "$lastrel" != "$expected" ]]; then | |
27 echo "$line" | |
28 echo "actual last major release without $revset is $lastrel" | |
29 echo | |
30 fi | |
31 fi | |
32 done |