1 #!/bin/bash |
|
2 # |
|
3 # produces two repositories with different common and missing subsets |
|
4 # |
|
5 # $ discovery-helper.sh REPO NBHEADS DEPT |
|
6 # |
|
7 # The Goal is to produce two repositories with some common part and some |
|
8 # exclusive part on each side. Provide a source repository REPO, it will |
|
9 # produce two repositories REPO-left and REPO-right. |
|
10 # |
|
11 # Each repository will be missing some revisions exclusive to NBHEADS of the |
|
12 # repo topological heads. These heads and revisions exclusive to them (up to |
|
13 # DEPTH depth) are stripped. |
|
14 # |
|
15 # The "left" repository will use the NBHEADS first heads (sorted by |
|
16 # description). The "right" use the last NBHEADS one. |
|
17 # |
|
18 # To find out how many topological heads a repo has, use: |
|
19 # |
|
20 # $ hg heads -t -T '{rev}\n' | wc -l |
|
21 # |
|
22 # Example: |
|
23 # |
|
24 # The `pypy-2018-09-01` repository has 192 heads. To produce two repositories |
|
25 # with 92 common heads and ~50 exclusive heads on each side. |
|
26 # |
|
27 # $ ./discovery-helper.sh pypy-2018-08-01 50 10 |
|
28 |
|
29 set -euo pipefail |
|
30 |
|
31 if [ $# -lt 3 ]; then |
|
32 echo "usage: `basename $0` REPO NBHEADS DEPTH" |
|
33 exit 64 |
|
34 fi |
|
35 |
|
36 repo="$1" |
|
37 shift |
|
38 |
|
39 nbheads="$1" |
|
40 shift |
|
41 |
|
42 depth="$1" |
|
43 shift |
|
44 |
|
45 leftrepo="${repo}-left" |
|
46 rightrepo="${repo}-right" |
|
47 |
|
48 left="first(sort(heads(all()), 'desc'), $nbheads)" |
|
49 right="last(sort(heads(all()), 'desc'), $nbheads)" |
|
50 |
|
51 leftsubset="ancestors($left, $depth) and only($left, heads(all() - $left))" |
|
52 rightsubset="ancestors($right, $depth) and only($right, heads(all() - $right))" |
|
53 |
|
54 echo '### building left repository:' $left-repo |
|
55 echo '# cloning' |
|
56 hg clone --noupdate "${repo}" "${leftrepo}" |
|
57 echo '# stripping' '"'${leftsubset}'"' |
|
58 hg -R "${leftrepo}" --config extensions.strip= strip --rev "$leftsubset" --no-backup |
|
59 |
|
60 echo '### building right repository:' $right-repo |
|
61 echo '# cloning' |
|
62 hg clone --noupdate "${repo}" "${rightrepo}" |
|
63 echo '# stripping:' '"'${rightsubset}'"' |
|
64 hg -R "${rightrepo}" --config extensions.strip= strip --rev "$rightsubset" --no-backup |
|