contrib/discovery-helper.sh
author Matt Harbison <matt_harbison@yahoo.com>
Sun, 23 Dec 2018 22:57:03 -0500
changeset 41065 0a7f582f6f1f
parent 40831 01c335afc997
permissions -rwxr-xr-x
largefiles: port wrapped functions to exthelper Things get interesting in the commit. I hadn't seen issue6033 on Windows, and yet it is now reproducible 100% of the time on Windows 10 with this commit. I didn't test Linux. (For comparison, after seeing this issue, I tested on the parent with --loop, and it failed 5 times out of over 1300 tests.) The strange thing is that largefiles has nothing to do with that test (it's not even mentioned there). It isn't autoloading run amuck- it occurs even if largefiles is explicitly disabled, and also if the entry in afterhgrcload() is commented out. It's also not the import of lfutil- I disabled that by copying the function into lfs and removing the import, and the problem still occurs. Experimenting further, it seems that the problem is isolated to 3 entries: exchange.pushoperation, hg.clone, and cmdutil.revert. If those decorators are all commented out, the test passes when run in a loop for awhile. (Obviously, some largefiles tests will fail.) But if any one is commented back in, the test fails immediately. I left one method related to wrapping the wire protocol, because it seemed more natural with the TODO. Also, exthelper doesn't support wrapping functions from another extension, only commands in another extension. I didn't try to figure out why rebase is both command wrapped and function wrapped.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40831
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     1
#!/bin/bash
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     2
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     3
# produces two repositories with different common and missing subsets
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     4
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     5
#   $ discovery-helper.sh REPO NBHEADS DEPT
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     6
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     7
# The Goal is to produce two repositories with some common part and some
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     8
# exclusive part on each side. Provide a source repository REPO, it will
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     9
# produce two repositories REPO-left and REPO-right.
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    10
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    11
# Each repository will be missing some revisions exclusive to NBHEADS of the
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    12
# repo topological heads. These heads and revisions exclusive to them (up to
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    13
# DEPTH depth) are stripped.
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    14
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    15
# The "left" repository will use the NBHEADS first heads (sorted by
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    16
# description). The "right" use the last NBHEADS one.
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    17
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    18
# To find out how many topological heads a repo has, use:
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    19
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    20
#   $ hg heads -t -T '{rev}\n' | wc -l
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    21
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    22
# Example:
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    23
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    24
#  The `pypy-2018-09-01` repository has 192 heads. To produce two repositories
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    25
#  with 92 common heads and ~50 exclusive heads on each side.
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    26
#
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    27
#    $ ./discovery-helper.sh pypy-2018-08-01 50 10
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    28
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    29
set -euo pipefail
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    30
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    31
if [ $# -lt 3 ]; then
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    32
     echo "usage: `basename $0` REPO NBHEADS DEPTH"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    33
     exit 64
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    34
fi
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    35
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    36
repo="$1"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    37
shift
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    38
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    39
nbheads="$1"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    40
shift
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    41
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    42
depth="$1"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
shift
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    44
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    45
leftrepo="${repo}-left"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    46
rightrepo="${repo}-right"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    47
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    48
left="first(sort(heads(all()), 'desc'), $nbheads)"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    49
right="last(sort(heads(all()), 'desc'), $nbheads)"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    50
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    51
leftsubset="ancestors($left, $depth) and only($left, heads(all() - $left))"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    52
rightsubset="ancestors($right, $depth) and only($right, heads(all() - $right))"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    53
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    54
echo '### building left repository:' $left-repo
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    55
echo '# cloning'
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    56
hg clone --noupdate "${repo}" "${leftrepo}"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    57
echo '# stripping' '"'${leftsubset}'"'
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    58
hg -R "${leftrepo}" --config extensions.strip= strip --rev "$leftsubset" --no-backup
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    59
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    60
echo '### building right repository:' $right-repo
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    61
echo '# cloning'
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    62
hg clone --noupdate "${repo}" "${rightrepo}"
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    63
echo '# stripping:' '"'${rightsubset}'"'
01c335afc997 contrib: add a helper script that help to build interesting repositories
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    64
hg -R "${rightrepo}" --config extensions.strip= strip --rev "$rightsubset" --no-backup