#!/bin/bash

if [ ! "$HG_SOURCE" = "push" ]; then
  # Only do this check when pushing changes, not when
  # bundling them or serving the repository over HTTP.
  exit 0
fi

descs=`hg outgoing --template "{desc}\n"`
result="$?"
if [ ! "$result" = "0" ]; then
  echo "Error: hg outgoing failed!"
  exit 1
fi

echo "$descs" | grep -q "NOT REVIEWED YET"
result="$?"
if [ "$result" = "0" ]; then
  echo "Error: Attempting to push an unreviewed patch!"
  exit 1
else
  exit 0
fi
