contrib/check-compat-strings.sh
branchmercurial-4.8
changeset 5366 62855e1ce9d8
parent 5192 f5b366a31740
equal deleted inserted replaced
5282:1bb465fad209 5366:62855e1ce9d8
       
     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