bundle2: safely read unpack data from part header

We use the same approach that the other unpack, as function is given the struct
format and his both responsible for reading the right amount of data from the
header and unpack the struct.

This give use flexibility if we decide to change the size of something in the
format before the release.

--HG--
extra : rebase_source : 72ab1f46d58f83657e3e112e874dccc042e2206a
bundle2: rename unbundle2 test command to statbundle2

We will introduce object to actually process the bundle, we need to keep the
simplistic unbundle around for the test.

--HG--
extra : rebase_source : 930c17a38a6bc225036325ee035283f223d6c567
bundle2: first version of a bundle processing

We now have a function that interpret part content.

This is a version early version of this function. It'll see major changes in
scope and API in future development. As for previous I'm just focussing on
getting minimal logic setup. Refining will happen with real world usage.
bundle2: introduce a `parthandler` decorator

Simple syntax sugar to register an handler for a new part type.
bundle2: add some distinction between mandatory and advisory part

Mandatory part cannot be ignored when unknown. We raise a simple KeyError
exception when this happen.

This is very early version of this logic, see inline comment for future
improvement lead.
bundle2: read the whole bundle from stream on abort

When the bundle processing abort on unknown mandatory parts, we now makes sure
all the bundle content is read. This avoid leaving the communication channel in
an unrecoverable state.
revsetbenchmark: remove python 2.7 dependency

revsetbenchmark.py used check_output which only exists in python 2.7. This
fixes it.
revset: improve _descendants performance

Previously revset._descendants would iterate over the entire subset (which is
often the entire repo) and test if each rev was in the descendants list. This is
really slow on large repos (3+ seconds).

Now we iterate over the descendants and test if they're in the subset.
This affects advancing and retracting the phase boundary (3.5 seconds down to
0.8 seconds, which is even faster than it was in 2.9). Also affects commands
that move the phase boundary (commit and rebase, presumably).

The new revsetbenchmark indicates an improvement from 0.2 to 0.12 seconds. So
future revset changes should be able to notice regressions.

I removed a bad test. It was recently added and tested '1:: and reverse(all())',
which has an amibiguous output direction.  Previously it printed in reverse order,
because we iterated over the subset (the reverse part). Now it prints in normal
order because we iterate over the 1:: . Since the revset itself doesn't imply an
order, I removed the test.
revset: improve roots revset performance

Previously we would iterate over every item in the subset, checking if it was in
the provided args. This often meant iterating over every rev in the repo.

Now we iterate over the args provided, checking if they exist in the subset.
On a large repo this brings setting phase boundaries (which use this revset
roots(X:: - X::Y)) down from 0.8 seconds to 0.4 seconds.

The "roots((tip~100::) - (tip~100::tip))" revset in revsetbenchmarks shows it
going from 0.12s to 0.10s, so we should be able to catch regressions here in the
future.

This actually introduces a regression in 'roots(all())' (0.2s to 0.26s) since
we're now using spansets, which are slightly slower to do containment checks on.
I believe this trade off is worth it, since it makes the revset O(number of
args) instead of O(size of repo).
tests: prevent test-hup from hanging forever if the transaction does not start

If the transaction fails to start because of some programing errors, the test
would stay stuck in this while loop forever.

We now added a basic safeguard that abort the loop if nothing happen in 10
seconds. 10 seconds sounds enough to let the server catch up and open a
transaction.

--HG--
extra : amend_source : 3e94a7630e1ffc94ebccd9da67300dfe91bab8e8