Validate paths before reading or writing files in repository or working dir.
Fixes security relevant
issue134.
Fixes running 'hg serve' with Windows executable and no explicit template path configured.
PY2EXE executables don't support __file__ but do place the directory of the
shared code library into sys.prefix.
Fixes bug 152.