1.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2+++ b/scripts/bundle-comp.sh Sun Jun 16 23:53:24 2024 +0000
1.3@@ -0,0 +1,35 @@
1.4+#!/usr/bin/env bash
1.5+# bundle a tar.zst archive of Mercurial repositories.
1.6+# must be absolute
1.7+BUNDLE="${1:-comp}"
1.8+WD=$(realpath .stash)
1.9+OUT=$WD
1.10+SRC_PATH=$HOME/src/$BUNDLE
1.11+
1.12+echo "Bundling $BUNDLE_NAME in $OUT..."
1.13+
1.14+rm -rf $OUT/*
1.15+mkdir -pv $OUT
1.16+mkdir -pv $WD/vc/hg/{zst,stream}
1.17+
1.18+cd $SRC_PATH
1.19+# Find all mercurial repositories, create bundles and dump them to $OUT dir.
1.20+for i in $(find . -name ".hg" | cut -c 3-); do
1.21+ echo ""
1.22+ echo "found hg repo: $i"
1.23+ cd $i/..
1.24+ echo "making zstd-v2 bundle..."
1.25+ hg bundle -a -t zstd-v2 $WD/vc/hg/zst/$(basename $(hg root)).hg.zst
1.26+ echo "making none-v2 bundle..."
1.27+ hg bundle -a -t none-v2 $WD/vc/hg/$(basename $(hg root)).hg
1.28+ echo "making stream bundle..."
1.29+ hg debugcreatestreamclonebundle $WD/vc/hg/stream/$(basename $(hg root)).hg.stream
1.30+ echo "... Done."
1.31+ cd $SRC_PATH
1.32+done
1.33+
1.34+# archive all *.hg bundles, final compression with zst
1.35+cd $WD/vc && tar -I 'zstd' -cf $OUT/$BUNDLE.tar.zst --exclude hg/hg.hg hg/*.hg
1.36+# tar -cf $OUT/$BUNDLE.tar.stream vc/stream/*.hg.stream
1.37+# tar -cf $OUT/$BUNDLE.tar vc/*.hg
1.38+echo "Done."