revset: changed last implementation to use lazy classes

Instead of using getitem just reverse the revision list and get the first
'lim' elements. With classes like spanset which are easily reversible this
will work faster.

Performance Benchmarking:

$ time hg log -qr "last(all())"
...

real  0m0.569s
user  0m0.447s
sys 0m0.122s

$ time ./hg log -qr "last(all())"
...

real  0m0.215s
user  0m0.150s
sys 0m0.063s
revset: added generatorset class with cached __contains__ method
pathencode: eliminate signed integer warnings

Compiling mercurial with the Sun Studio compiler gives seven copies of the
following warning on pathencode.c:

    line 533: warning: initializer will be sign-extended: -1

Using explicit unsigned literals silences it.

--HG--
branch : stable
merge with stable

--HG--
extra : amend_source : bf64f8ef7f567e419a738f4bf10b42bf3cb96c20