Make tag detection less prone to generate false negatives.

Ported from KDAB SVN copy. I assume that this does something useful...
Original commit message follows.

Tag detection is now more likely to generate false positives, but it
still seems unlikely that a path contains "tags/" if it is not a
tagged revision.
Print some more information.

Ported from KDAB SVN copy. Original commit message follows.

Try to diagnose why tagged packages generated by buildbot still contain
"-r<hex string>" in their version string.
VCS support improvements.

Ported from KDAB SVN copy. Original commit messages follow.

---
Find the first .svn or .git directory to figure out the repository type.

Trying git first like it was done before didn't work in case of an svn
repository in a git repository, which is the case on our buildbot setup.
It always looked like git.
---
Detect tagged versions in git. Also consolidate try-except blocks.
---
Make git-svn work again. I haven't tested it, though.
---
This probably works better (gives the process a chance to fail).
---
Fix out-of-source builds where the build directory is not *in* the
source directory.
print_stderr isn't defined, regular print will do.

Ported from KDAB SVN copy.
Merge pull request #2 from ahartmetz/svn-changes

Changes from our autogen copy in SVN.