repoview: drop duplicated lookup

We are already looking for local tags on the line above. We can safely drop
this extra lookup.

--HG--
extra : rebase_source : 76ac49550350f2420c4da0078c2a59c142fae3f3
repoview: make the conversion from node to rev explicit while computing hidden

You cannot use `repo[...]` lookup here. 1. It is slow 2. It is very likely to
trigger a hidden computation itself, entering an infinite loop.

--HG--
extra : rebase_source : bd3fb89e931f70d30620836a5c22f26c1664be93
bundle2: add a "check:heads" handler

This part is intended to hold the same role as the `heads` argument of the
unbundle function. The client fill it with the known heads at bundle time and
the server will abort if its heads changed.

--HG--
extra : rebase_source : c24c9e88768d9d93250f97f4a2af11779a2564ef
bundle2: allow using bundle2 for push

We now support bundle2 for local push. The unbundle function has to detect
which version of the bundle to use since the return type is different.

Note that push error handling is currently nonexistent. This is one of the
reasons why bundle2 is still disabled by default.

--HG--
extra : rebase_source : 6302733e7f552964fdd123317c4987c909a6a1bc
bundle2: use headerless HG10UN stream in changegroup

Using `readbundle` in the part handlers creates a circular import hell. We are
now using a simple `HG10UN` stream with no header. Some parameters may
later be introduced on the part to change parameter.

Producers are updated as well.

--HG--
extra : rebase_source : 1e02b5aa27e85b2a7dd5b1fe3d58c72eb9f294cd
extra : amend_source : 5fd300d4f95ab2d391f360d916c12a66684477b6
bundle2: move `readbundle` into the `exchange` module

The `readbundle` function is going to understand the bundle2 header. We move the
function to a more suitable place before making any other changes.

--HG--
extra : rebase_source : 8ce443b9999668c876d06a07829d0ada3d7052bc
bundle2: add a ui argument to readbundle

The bundle2 unbundler needs a ui argument. We are now passing this information
to `readbundle`.

--HG--
extra : rebase_source : 2eec056cb89bc50296aa3f9095936b35c4d0525c
bundle2: prepare readbundle to return more that one type of bundle

We first read 4 bytes to get the `HG10` bytes then we read the compression scheme
if this is `HG10`. This prepares the code for the arrival of `HG20` handling.

--HG--
extra : rebase_source : 427ca89da99e50d57a3bb4f2358e0a7206141adc
bundle2: make header reading optional

The `readbundle` function will consume the 4 first bytes to dispatch between
various unbundler. We introduce a way to inform `unbundle20` that the header
has been read and it can be trusted.

--HG--
extra : rebase_source : 6f840c9d98fe2d63cbd20a235fd718446228d82b
bundle2: let readbundle return unbundle20

The `readbundle` function can now recognize a bundle2 stream and return the
appropriate unbundler. This is required for proper bundle2 support over the
wire.

--HG--
extra : rebase_source : bf41eda4da13911502d42861e311df9359331247
bundle2: return a stream from exchange.getbundle

For friendliness with the wire protocol implementation, the `exchange.getbundle` now
returns a binary stream when asked for a bundle2. We detect a bundle2 request and
upgrade the binary stream to an unbundler object.

In the future the unbundler may gain feature to look like a binary stream, but
we are not quite there yet.

--HG--
extra : rebase_source : 7e6033170f8b1204b234030f0714e777628eb1fd
bundle2: allow bundle2 for pulling over the wire

This changeset makes `wireprotocol` peers advertise bundle2 capability and
comply with bundle2 `getbundle` requests.

Note that advertising bundle2 could make a client try to use it for push. Such
pushes would fail. However, I do not expect any human being to have enabled
bundle2 on their server yet.

--HG--
extra : rebase_source : 4ccccf3e1b0ab0dc18ea7c523dd4ffee1cd26a2b
bundle2: feed a binary stream to `peer.unbundle`

This input will have to travel over the wire anyway, so we feed the peer method
with a simple binary stream and rely on the server side to use `readbundle`
to create the python object.

The test output changes because the bundle is created marginally sooner and the
debug output interleaves in a different way.

--HG--
extra : rebase_source : 378857d27688b629396c431397af5dcc1ddace79
bundle2: return a bundle20 object from exchanges.unbundle

When a bundle2 is pushed we return a bundle instead of an integer. We use to
return a binary stream. We now return a `bundle20` bundler to make the life of
wireprotocol implementation simpler.

--HG--
extra : rebase_source : 333f33a010bdf58264a35f6f85d3cb5d1dc34977
wireproto: add a _calltwowaystream method on wirepeer

This method will be used by bundle2 pushes. It calls a command, feeds it with a
stream and receives another stream in reply.

Actual implementation for ssh and http will be done in later changesets.

--HG--
extra : rebase_source : 39e447ac0cd35955a62dd48792c3c3c7f22a77c2
sshpeer: add implementation of _calltwowaystream

This implements the call needed by bundle2. The error handling is a bit flaky
right now, but bundle2 error handling in general is still flaky anyway. Bundle2
is still disabled by default, I do not expect this to be a problem.

--HG--
extra : rebase_source : 3f6d6096536a46347b94fb0573473fe72d6b5b0a
httppeer: support for _calltwowaystream

This new method is now supported by http too.

--HG--
extra : rebase_source : c4dd664fe345104811b12e1782666a7df5087c9c
bundle2: support for push over the wire

We use the new method defined in the past changeset to send a bundle2 stream and
receive one in reply. The http version is missing remote output support. This
will be done later using a bundle part.

--HG--
extra : rebase_source : 568f57359232238c726a9310a1c115d6c0d82b74
convert: backout b75a04502ced and 9616b03113ce - tagmap

Tagmap solves a very specific use case. It would be better to have a more
generic solution than to have to maintain this forever.

Tagmap has not been released yet and removing it now will not break any
backward compatibility contract.

There is no test coverage for tagmap but it seems like the same can be achieved
with a (relatively) simple and much more powerful custom extension:

import hgext.convert.hg
def f(tag):
    return tag.replace('some', 'other')
class source(hgext.convert.hg.mercurial_source):
    def gettags(self):
        return dict((f(tag), node)
                    for tag, node in in super(source, self).gettags().items())
    def getfile(self, name, rev):
        data, flags = super(source, self).getfile(name, rev)
        if name == '.hgtags':
            data = ''.join(l[:41] + f(l[41:]) + '\n' for l in data.splitlines())
        return data, flags
hgext.convert.hg.mercurial_source = source

--HG--
extra : rebase_source : f436aceb18ff1d0137dc8b5681f1ad896fbe938e
convert: backout 81cf597dafa9 and a3545c3104aa -closemap

Closemap solves a very specific use case. It would be better to have a more
generic solution than to have to maintain this forever.

Closemap has not been released yet and removing it now will not break any
backward compatibility contract.

There is no test coverage for closemap but it seems like the same can be
achieved with a simple and much more powerful custom extension:

import hgext.convert.hg
class source(hgext.convert.hg.mercurial_source):
    def getcommit(self, rev):
        c = super(source, self).getcommit(rev)
        if rev in ['''
d643f67092ff123f6a192d52f12e7d123dae229f
9117c6561b0bd7792fa13b50d28239d51b78e51f
f368a1c302d5b87506f7edb13769e591e063d7ea
''']:
            c.extra = c.extra.copy()
            c.extra['close'] = '1'
        return c
hgext.convert.hg.mercurial_source = source

--HG--
extra : rebase_source : 59eaf0877122d0aaa519a4e35ea0462500527cf6