contrib/phab-refresh-stack.sh
author Valentin Gatien-Baron <vgatien-baron@janestreet.com>
Fri, 06 Aug 2021 16:27:17 -0400
changeset 47875 0fb328bb2459
parent 46044 9be5db6148fb
child 48697 fba2d7fab11e
permissions -rwxr-xr-x
debugrebuildfncache: add a cheaper option to rebuild the fncache On my repository, debugrebuildfncache takes 5-10min with the lock. With the flag added in this commit, it takes 10s. The tradeoff is that it only recovers from certain kinds of corruptions. It is intended to to recover faster from fncaches broken by a revlog split during a transaction that ends up being rolled back. Differential Revision: https://phab.mercurial-scm.org/D11265

#!/bin/bash
set -eu

revision_in_stack=`hg log \
    --rev '.#stack and ::. and topic()' \
    -T '\nONE-REV\n' \
    | grep 'ONE-REV' | wc -l`
revision_on_phab=`hg log \
    --rev '.#stack and ::. and topic() and desc("re:\nDifferential Revision: [^\n]+D\d+$")'\
    -T '\nONE-REV\n' \
    | grep 'ONE-REV' | wc -l`

if [[ $revision_in_stack -eq 0 ]]; then
    echo "stack is empty" >&2
    exit 0
fi

if [[ $revision_on_phab -eq 0 ]]; then
    echo "no tracked diff in this stack" >&2
    exit 0
fi

if [[ $revision_on_phab -lt $revision_in_stack ]]; then
    echo "not all stack changesets (${revision_in_stack}) have matching Phabricator Diff (${revision_on_phab})" >&2
    exit 2
fi

if [[ "$PHABRICATOR_TOKEN" == "" ]]; then
    echo 'missing $PHABRICATOR_TOKEN variable' >&2
    exit 2
fi

hg \
--config extensions.phabricator= \
--config phabricator.url=https://phab.mercurial-scm.org/ \
--config phabricator.callsign=HG \
--config auth.phabricator.schemes=https \
--config auth.phabricator.prefix=phab.mercurial-scm.org \
--config auth.phabricator.phabtoken=$PHABRICATOR_TOKEN \
phabsend --rev '.#stack and ::. and topic()' \
"$@"