view hg-web/repository_sync_test.sh @ 250:745fd127b2a1

[seobeo] Add bounded worker interface Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Tue, 04 Aug 2026 06:23:37 -0700
parents c5129452493e
children
line wrap: on
line source

#!/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 '.'
)" == ".." ]]