changeset 45990:5de27798d2af

contrib: add a small script to refresh all diff in the current stack This will be useful to introduce automatic refresh through heptapod. Differential Revision: https://phab.mercurial-scm.org/D9460
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 28 Nov 2020 14:11:54 +0100
parents 60523483897c
children c7f40562389f
files contrib/phab-refresh-stack.sh
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/phab-refresh-stack.sh	Sat Nov 28 14:11:54 2020 +0100
@@ -0,0 +1,34 @@
+#!/bin/bash
+set -eu
+
+revision_in_stack=`hg log --rev '.#stack and ::.' -T '\nONE-REV\n' | grep 'ONE-REV' | wc -l`
+revision_on_phab=`hg log --rev '.#stack and ::. 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 1
+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 ::.'