[PATCH 1 of 4 "] discovery-helper: add an extra argument to generate only one repo

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Mar 10 15:19:11 EDT 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1552077537 -3600
#      Fri Mar 08 21:38:57 2019 +0100
# Node ID acc5042401309c9daaa1fd08b947c5432901199b
# Parent  c1017bceb6eca60b1e77432aaee837f66e1ba421
# EXP-Topic perf-utils
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r acc504240130
discovery-helper: add an extra argument to generate only one repo

This is useful to generate left and right in parallel when dealing with very
large repositories.

diff --git a/contrib/perf-utils/discovery-helper.sh b/contrib/perf-utils/discovery-helper.sh
--- a/contrib/perf-utils/discovery-helper.sh
+++ b/contrib/perf-utils/discovery-helper.sh
@@ -28,9 +28,13 @@
 
 set -euo pipefail
 
+printusage () {
+     echo "usage: `basename $0` REPO NBHEADS DEPTH [left|right]" >&2
+}
+
 if [ $# -lt 3 ]; then
-     echo "usage: `basename $0` REPO NBHEADS DEPTH"
-     exit 64
+    printusage
+    exit 64
 fi
 
 repo="$1"
@@ -42,6 +46,24 @@ shift
 depth="$1"
 shift
 
+doleft=1
+doright=1
+if [ $# -gt 1 ]; then
+    printusage
+    exit 64
+elif [ $# -eq 1 ]; then
+    if [ "$1" == "left" ]; then
+        doleft=1
+        doright=0
+    elif [ "$1" == "right" ]; then
+        doleft=0
+        doright=1
+    else
+        printusage
+        exit 64
+    fi
+fi
+
 leftrepo="${repo}-${nbheads}h-${depth}d-left"
 rightrepo="${repo}-${nbheads}h-${depth}d-right"
 
@@ -52,17 +74,25 @@ leftsubset="ancestors($left, $depth) and
 rightsubset="ancestors($right, $depth) and only($right, heads(all() - $right))"
 
 echo '### creating left/right repositories with missing changesets:'
-echo '# left  revset:' '"'${leftsubset}'"'
-echo '# right revset:' '"'${rightsubset}'"'
+if [ $doleft -eq 1 ]; then
+    echo '# left  revset:' '"'${leftsubset}'"'
+fi
+if [ $doright -eq 1 ]; then
+    echo '# right revset:' '"'${rightsubset}'"'
+fi
 
-echo '### building left repository:' $left-repo
-echo '# cloning'
-hg clone --noupdate "${repo}" "${leftrepo}"
-echo '# stripping' '"'${leftsubset}'"'
-hg -R "${leftrepo}" --config extensions.strip= strip --rev "$leftsubset" --no-backup
+if [ $doleft -eq 1 ]; then
+    echo '### building left repository:' $left-repo
+    echo '# cloning'
+    hg clone --noupdate "${repo}" "${leftrepo}"
+    echo '# stripping' '"'${leftsubset}'"'
+    hg -R "${leftrepo}" --config extensions.strip= strip --rev "$leftsubset" --no-backup
+fi
 
-echo '### building right repository:' $right-repo
-echo '# cloning'
-hg clone --noupdate "${repo}" "${rightrepo}"
-echo '# stripping:' '"'${rightsubset}'"'
-hg -R "${rightrepo}" --config extensions.strip= strip --rev "$rightsubset" --no-backup
+if [ $doright -eq 1 ]; then
+    echo '### building right repository:' $right-repo
+    echo '# cloning'
+    hg clone --noupdate "${repo}" "${rightrepo}"
+    echo '# stripping:' '"'${rightsubset}'"'
+    hg -R "${rightrepo}" --config extensions.strip= strip --rev "$rightsubset" --no-backup
+fi


More information about the Mercurial-devel mailing list