revset: added cached generated list on generatorset

This allows to iterate the generatorset more than once.
run-tests.py: work when --with-hg is set to system hg

Previously we'd always assume that --with-hg is a script in a user directory,
and would write out a 'python' symlink to the same location. That didn't work
if --with-hg was set to a system installation of hg, e.g. /usr/bin/hg.

Introduce a TMPBINDIR directory which is used to write out the python symlink.
util: debugstacktrace, flush before and after writing

Close another stream (default stdout, which often is buffered) before writing
to the primary stream (default stderr, which often is unbuffered). The primary
stream is also flushed after writing (in case it is buffered).

This fixes non-deterministic output order, especially on windows.
tests: backout a82de9dc4f77, debugstacktrace is now stable, drop workaround
log: describe graph symbols in the help

I wondered what 'x' meant and didn't find it described anywhere.
rebase: fix 'rebase onto %d starting from %s' - show root instead of list repr

The debug statement is already in a 'for root in roots' so it was probably the
intention to show root instead of roots. Do that.
rebase: show nice list instead of set repr for 'computed skipped revs' debug
hooks: move logging of hook name to after we have found the hook

We do not expect the finding process to take a significant amount of time - it
is the execution time of the hook we care about.
hooks: for python hooks, consistently use __name__ etc as name, not the repr

There is no reason to expose unnecessary Python implementation details and
memory locations, also not in debug mode.

readablefunc was already creating a nice name - we move that functionality
up and reuse it.

We consider having a __call__ and being types.FunctionType sufficiently
similar and unify these two to just using the existing check for __call__.
comments: fix minor spelling issues found with spell checker
phases: make order of debug output 'removing unknown node' deterministic