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

login
register
mail settings
Submitter phabricator
Date Nov. 29, 2020, 11:20 a.m.
Message ID <differential-rev-PHID-DREV-cwnjtomjtl3riqxajafz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47738/
State Superseded
Headers show

Comments

phabricator - Nov. 29, 2020, 11:20 a.m.
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/D9460

AFFECTED FILES
  contrib/phab-refresh-stack.sh

CHANGE DETAILS




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

Patch

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'