contrib/phab-refresh-stack.sh
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 03 Dec 2020 08:09:56 +0100
changeset 46016 372409eb5cd1
parent 45990 5de27798d2af
child 46043 024f90fc01b5
permissions -rwxr-xr-x
phab-refresh: do not error out when the stack is empty Actually, empty stack is easier to get than I expected (and harmless). When a stack is publish, heptapod will detect the even, empty the stack (triggering CI) and "forgetting" the branch afterward. So we stop returning as error in this case. Differential Revision: https://phab.mercurial-scm.org/D9513
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45990
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     1
#!/bin/bash
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     2
set -eu
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     3
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     4
revision_in_stack=`hg log --rev '.#stack and ::.' -T '\nONE-REV\n' | grep 'ONE-REV' | wc -l`
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     5
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`
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     6
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     7
if [[ $revision_in_stack -eq 0 ]]; then
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
     8
    echo "stack is empty" >&2
46016
372409eb5cd1 phab-refresh: do not error out when the stack is empty
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45990
diff changeset
     9
    exit 0
45990
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    10
fi
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    11
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    12
if [[ $revision_on_phab -eq 0 ]]; then
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    13
    echo "no tracked diff in this stack" >&2
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    14
    exit 0
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    15
fi
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    16
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    17
if [[ $revision_on_phab -lt $revision_in_stack ]]; then
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    18
    echo "not all stack changesets (${revision_in_stack}) have matching Phabricator Diff (${revision_on_phab})" >&2
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    19
    exit 2
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    20
fi
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    21
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    22
if [[ "$PHABRICATOR_TOKEN" == "" ]]; then
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    23
    echo 'missing $PHABRICATOR_TOKEN variable' >&2
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    24
    exit 2
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    25
fi
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    26
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    27
hg \
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    28
--config extensions.phabricator= \
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    29
--config phabricator.url=https://phab.mercurial-scm.org/ \
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    30
--config phabricator.callsign=HG \
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    31
--config auth.phabricator.schemes=https \
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    32
--config auth.phabricator.prefix=phab.mercurial-scm.org \
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    33
--config auth.phabricator.phabtoken=$PHABRICATOR_TOKEN \
5de27798d2af contrib: add a small script to refresh all diff in the current stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
    34
phabsend --rev '.#stack and ::.'