tools/rgit2hg.sh
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15859 7b1d6dfa3173
parent 11517 b3ee79e8e3b9
permissions -rwxr-xr-x
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10649
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     1
#!/bin/sh
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     2
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     3
#HW_HG=
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     4
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     5
if [ -z "$1" ]; then
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     6
    echo 'You have to supply at least one hedgewars git revision as parameter!' >&2
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     7
    exit
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     8
fi
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
     9
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    10
if [ -z "$HW_HG" ]; then 
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    11
    HW_HG="$PWD"
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    12
fi
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    13
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    14
if [ ! -d "$HW_HG/.hg" ]; then
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    15
    echo 'You have to set HW_HG (inside script or env) to a repo clone OR call this script from inside the repository!' >&2
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    16
    exit
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    17
fi
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    18
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    19
while [ ! -z "$1" ]; do
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    20
    echo
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    21
    echo
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    22
    echo '---------------------------------------------------------------'
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    23
    echo "$1"
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    24
    echo '---------------------------------------------------------------'
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    25
    url="https://github.com/hedgewars/hw/commit/$1"
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    26
    echo "Checking $url ..."
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    27
    echo
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    28
    page=$(wget -q -O- "$url")
11514
5d804405964d fix script for resolving git commit id to hg commit id (github page format changed; hw hg repo location too)
sheepluva
parents: 10649
diff changeset
    29
    author=$(echo "$page" | sed -rn '1,/"user-mention"/{s/^.*"user-mention"( *[^>]*)?> *([^ <]*).*$/\2/ p}')
10649
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    30
    if [ -z "$author" ]; then
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    31
        echo 'Couldn'\''t find author! Skipping '"$1"' ...' >&2
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    32
        shift
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    33
        continue
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    34
    fi
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    35
    echo 'Found author: '"$author"
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    36
    date=$(echo "$page" | sed -rn 's/^.*<time datetime="([^T]+)T([^Z]+).*/\1 \2 +0000/ p')
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    37
    if [ -z "$date" ]; then
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    38
        echo 'Couldn'\''t find date! Skipping '"$1"' ...' >&2
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    39
        shift
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    40
        continue
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    41
    fi
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    42
    echo 'Found date:   '"$date"
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    43
    echo
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    44
    echo 'Checking mercurial log for matches ...'
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    45
    echo
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    46
    result=$(hg log -R "$HW_HG" -u "$author" -d "$date" -v -l1)
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    47
    if [ -z "$result" ]; then
11517
b3ee79e8e3b9 find hg revision even if github author name is not the same as hg author (kodabb vs koda)
sheepluva
parents: 11514
diff changeset
    48
        echo 'No match with this author'\''s name. It might differ, so let'\''s try using date only ...'
b3ee79e8e3b9 find hg revision even if github author name is not the same as hg author (kodabb vs koda)
sheepluva
parents: 11514
diff changeset
    49
        echo
b3ee79e8e3b9 find hg revision even if github author name is not the same as hg author (kodabb vs koda)
sheepluva
parents: 11514
diff changeset
    50
        result=$(hg log -R "$HW_HG" -d "$date" -v)
b3ee79e8e3b9 find hg revision even if github author name is not the same as hg author (kodabb vs koda)
sheepluva
parents: 11514
diff changeset
    51
    fi
b3ee79e8e3b9 find hg revision even if github author name is not the same as hg author (kodabb vs koda)
sheepluva
parents: 11514
diff changeset
    52
    if [ -z "$result" ]; then
10649
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    53
        echo 'No match :('
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    54
        shift
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    55
        continue
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    56
    fi
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    57
    rev=$(echo "$result" | sed 's/^.*://;q')
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    58
    echo 'Found match: r'"$rev"
11514
5d804405964d fix script for resolving git commit id to hg commit id (github page format changed; hw hg repo location too)
sheepluva
parents: 10649
diff changeset
    59
    echo 'Link:        http://hg.hedgewars.org/hedgewars/rev/'"$rev"
10649
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    60
    echo
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    61
    echo "$result"
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    62
    # proceed to next parameter
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    63
    shift
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    64
done
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    65
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    66
echo
d83897fed816 small shell script that accepts hedgewars git revisions as parameters and will try to find the respective mercurial revision
sheepluva
parents:
diff changeset
    67