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

login
register
mail settings
Submitter Pierre-Yves David
Date March 10, 2019, 7:19 p.m.
Message ID <acc5042401309c9daaa1.1552245551@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/39203/
State Accepted
Headers show

Comments

Pierre-Yves David - March 10, 2019, 7:19 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Pulkit Goyal - March 10, 2019, 10:05 p.m.
On Sun, Mar 10, 2019 at 10:28 PM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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.
>

Queued the series, many thanks!

Patch

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