Mercurial
diff hg-web/repository_sync_test.sh @ 249:c5129452493e
[deploy] Bundle Mercurial with hg-web
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 04 Aug 2026 04:16:45 -0700 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hg-web/repository_sync_test.sh Tue Aug 04 04:16:45 2026 -0700 @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +if [[ -n "${RUNFILES_DIR:-}" ]]; then + source "$RUNFILES_DIR/bazel_tools/tools/bash/runfiles/runfiles.bash" +elif [[ -n "${RUNFILES_MANIFEST_FILE:-}" ]]; then + runfiles_library="$( + grep -sm1 '^bazel_tools/tools/bash/runfiles/runfiles.bash ' \ + "$RUNFILES_MANIFEST_FILE" | cut -d' ' -f2- + )" + source "$runfiles_library" +else + echo "Bazel runfiles are unavailable." >&2 + exit 1 +fi + +hg_binary="$(rlocation _main/third_party/mercurial/runtime/bin/hg)" +root="${TEST_TMPDIR:?}/repository-sync" +source_repository="$root/source" +production_repository="$root/production" +bundle="$root/workspace.hg" +mkdir -p "$root" + +HGRCPATH= "$hg_binary" init "$source_repository" +printf 'base\n' > "$source_repository/file.txt" +HGRCPATH= "$hg_binary" --cwd "$source_repository" add file.txt +HGRCPATH= "$hg_binary" --cwd "$source_repository" \ + commit -u test -m base + +HGRCPATH= "$hg_binary" clone \ + "$source_repository" "$production_repository" + +printf 'workspace\n' >> "$source_repository/file.txt" +HGRCPATH= "$hg_binary" --cwd "$source_repository" \ + commit -u test -m workspace + +printf 'production\n' >> "$production_repository/file.txt" +HGRCPATH= "$hg_binary" --cwd "$production_repository" \ + commit -u test -m production + +HGRCPATH= "$hg_binary" --repository "$source_repository" \ + bundle --all "$bundle" +HGRCPATH= "$hg_binary" --repository "$production_repository" \ + pull "$bundle" + +descriptions="$( + HGRCPATH= "$hg_binary" --repository "$production_repository" \ + log -T '{desc}\n' +)" +grep -qx workspace <<<"$descriptions" +grep -qx production <<<"$descriptions" +[[ "$( + HGRCPATH= "$hg_binary" --repository "$production_repository" \ + heads -T '.' +)" == ".." ]]