Created
August 4, 2016 10:19
-
-
Save tailhook/702005e1765ef3f749dd4a95422fbc95 to your computer and use it in GitHub Desktop.
Mercurial sync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
WORKDIR=/tmp/repo-sync-workdir | |
# Read all the branches in the last 24 hours when starting to make sure we | |
# don't get out of sync | |
branches="$(hg log --template '{branch}\n' -d 'yesterday to now')" | |
trap "true" USR1 # This is a signal to wakeup from sleeping | |
echo $$ > "$WORKDIR/syncer.pid" | |
if [ -f "$WORKDIR/branches" ]; then | |
mv -f "$WORKDIR/branches" "$WORKDIR/tmpbranches" | |
branches="$branches $(cat $WORKDIR/tmpbranches)" | |
rm "$WORKDIR/tmpbranches" | |
fi | |
branches="$(echo $branches | sort -u)" | |
git fetch origin $branches | |
git push origin $branches | |
while true; do | |
if [ -f "$WORKDIR/branches" ]; then | |
mv -f "$WORKDIR/branches" "$WORKDIR/tmpbranches" | |
branches="$(cat $WORKDIR/tmpbranches | sort -u)" | |
rm "$WORKDIR/tmpbranches" | |
git fetch origin $branches | |
git push origin $branches | |
sleep 1 # Don't wakeup more frequently than every one second | |
else | |
sleep 600 # recheck in ten minutes or on signal | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
WORKDIR=/tmp/repo-sync-workdir | |
branch="$(hg log -r $HG_NODE -T "{branch}")" | |
[ -d $WORKDIR ] || mkdir $WORKDIR | |
echo $branch >> $WORKDIR/branches | |
kill -USR1 "$(cat $WORKDIR/syncer.pid)" || true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment