TEST: replacing a symlink by a directory
find out what a SyncItem was in the previous revision
FIX: dirent deletion based on new type
TEST: replace also a regular file
Merge pull request #374 from reneme/fix-CVM-258

FIX: Replace File or Symlink by Directory Lead to Publish Crash

This fixes the following error condition:
We have a regular file or a symlink 'foo' in a CVMFS revision. In the following transaction we replace 'foo' by a directory.

Internally the publishing process determines what to do by comparing readonly and scratch dir. When it finds an opaque directory in the scratch dir and the readonly dir contains a dirent with the same name, it tries to replace this directory. I.e. calling RemoveRecursively() on the old dirent and Add() on the new directory.

The problem arises, when the old dirent actually was no directory but a symlink or a regular file. RemoveRecursively() will try to opendir() a regular file and die.

This fixes the issue by determining the required 'delete'-action in Replace() on the overwritten dirent not on the overwriting one.

Additionally it adds a regression test.