D9458: contrib: add a small script to refresh all diff in the current stack

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Sun Nov 29 11:19:56 UTC 2020


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will be useful to introduce automatic refresh through heptapod.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9458

AFFECTED FILES
  contrib/phab-refresh-stack.sh

CHANGE DETAILS

diff --git a/contrib/phab-refresh-stack.sh b/contrib/phab-refresh-stack.sh
new file mode 100755
--- /dev/null
+++ b/contrib/phab-refresh-stack.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+revision_in_stack=`hg log --rev '.#stack' -T '\nONE-REV\n' | grep 'ONE-REV' | wc -l`
+revision_on_phab=`hg log --rev '.#stack 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_in_phab -eq 0 ]]; then
+    echo "no tracked diff in this stack" >&2
+    exit 0
+fi
+
+if [[ $revision_in_phab -lt $revision_in_stack ]]; then
+    echo "not all stack changesets (${revision_in_stack}) have matching Phabricator Diff (${revision_in_phab})" >&2
+    exit 2
+fi
+
+if [[ "$PHABRICATOR_TOKEN" == "" ]]; then
+    echo 'missing $PHABRICATOR_TOKEN  variable' >&2
+    exit 2
+fi
+
+hg \
+--config extensions.phabricator= \
+phabricator.url=https://phab.mercurial-scm.org/ \
+phabricator.callsign=HG \
+auth.phabricator.schemes=https \
+auth.phabricator.prefix=phab.mercurial-scm.org \
+auth.hg.phabtoken=$PHABRICATOR_TOKEN \
+phabsend --rev '.#stack'



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list