#!/bin/bash
# vim:sw=2:et
echo=
echo=echo

usage()
{
  echo "$0 <path_to_orig_tree> <path_to_updated_tree>"
  exit 1
}

orig_tree=$1
test -n "$orig_tree" -a -d "$orig_tree" || usage
updated_tree=$2
test -n "$updated_tree" -a -d "$updated_tree" || usage

for path in $(find "$updated_tree/docs/" -name .svn -prune -o -type f -name '*.docbook' -print); do
  d=$(dirname "$path/" | sed -e "s,$updated_tree/,,")
  p=$(basename "$path")

  case $d/$p in
    *desktop_*)
      continue
      ;;
    *others/*)
      continue
      ;;
    *kdenonbeta/*)
      continue
      ;;
    *extragear-*/*)
      continue
      ;;
    *kdekiosk*/*)
      continue
      ;;
    *playground*/*)
      continue
      ;;
    *kdereview*/*)
      continue
      ;;
    *koffice*/*)
      continue
      ;;
    esac

  if test ! -f "$orig_tree/$d/$p" -a -f "$updated_tree/$d/$p"; then
    diff -d --label /dev/null --unidirectional-new-file -ur -x.svn \
      $orig_tree/$d/$p $updated_tree/$d/$p \
      | sed -e "s,^\+\+\+ $updated_tree/,+++ ,"
  else
    diff -d --label $d/$p $orig_tree/$d/$p $updated_tree/$d/$p -u \
      | sed -e "s,^\+\+\+ $updated_tree/,+++ ,"
  fi
done
