Mercurial > hg
view tests/test-bundle2-pushback.t @ 40923:3ed77780f4a6
wireprotov2: send linknodes to emitfilerevisions()
Previously, linknodes were calculated within emitfilerevisions() by
using filectx.introrev(), which would always use the linkrev/linknode
as recorded by storage. This is wrong for cases where the receiver
doesn't have the changeset the linknode refers to.
This commit changes the logic for linknode emission so the mapping
of filenode to linknode is computed by the caller and passed into
emitfilerevisions().
As part of the change, linknodes for "filesdata" in the
haveparents=False case are now correct: the existing code performed a
manifest walk and it was trivial to plug in the correct linknode.
However, behavior for the haveparents=True case is still wrong
because it relies on filtering linkrevs against the outgoing set in
order to determine what to send. This will be fixed in a subsequent
commit.
The change test test-wireproto-exchangev2-shallow.t is a bit wonky.
The test repo has 6 revisions. The changed test is performing a shallow
clone with depth=1. So, only file data for revision 5 is present
locally. So, the new behavior of associating the linknode with
revision 5 for every file revision seems correct. Of course, when
backfilling old revisions, we'll want to update the linknode. But
this problem requires wire protocol support and we'll cross that
bridge later.
Differential Revision: https://phab.mercurial-scm.org/D5405
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 10 Dec 2018 18:04:12 +0000 |
parents | 5abc47d4ca6b |
children | c70bdd222dcd |
line wrap: on
line source
#testcases sshv1 sshv2 #if sshv2 $ cat >> $HGRCPATH << EOF > [experimental] > sshpeer.advertise-v2 = true > sshserver.support-v2 = true > EOF #endif $ cat > bundle2.py << EOF > """A small extension to test bundle2 pushback parts. > Current bundle2 implementation doesn't provide a way to generate those > parts, so they must be created by extensions. > """ > from __future__ import absolute_import > from mercurial import bundle2, exchange, pushkey, util > def _newhandlechangegroup(op, inpart): > """This function wraps the changegroup part handler for getbundle. > It issues an additional pushkey part to send a new > bookmark back to the client""" > result = bundle2.handlechangegroup(op, inpart) > if b'pushback' in op.reply.capabilities: > params = {b'namespace': b'bookmarks', > b'key': b'new-server-mark', > b'old': b'', > b'new': b'tip'} > encodedparams = [(k, pushkey.encode(v)) for (k,v) in params.items()] > op.reply.newpart(b'pushkey', mandatoryparams=encodedparams) > else: > op.reply.newpart(b'output', data=b'pushback not enabled') > return result > _newhandlechangegroup.params = bundle2.handlechangegroup.params > bundle2.parthandlermapping[b'changegroup'] = _newhandlechangegroup > EOF $ cat >> $HGRCPATH <<EOF > [ui] > ssh = "$PYTHON" "$TESTDIR/dummyssh" > username = nobody <no.reply@example.com> > > [alias] > tglog = log -G -T "{desc} [{phase}:{node|short}]" > EOF Set up server repository $ hg init server $ cd server $ echo c0 > f0 $ hg commit -Am 0 adding f0 Set up client repository $ cd .. $ hg clone ssh://user@dummy/server client -q $ cd client Enable extension $ cat >> $HGRCPATH <<EOF > [extensions] > bundle2=$TESTTMP/bundle2.py > EOF Without config $ cd ../client $ echo c1 > f1 $ hg commit -Am 1 adding f1 $ hg push pushing to ssh://user@dummy/server searching for changes remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files remote: pushback not enabled $ hg bookmark no bookmarks set $ cd ../server $ hg tglog o 1 [public:2b9c7234e035] | @ 0 [public:6cee5c8f3e5b] With config $ cd ../client $ echo '[experimental]' >> .hg/hgrc $ echo 'bundle2.pushback = True' >> .hg/hgrc $ echo c2 > f2 $ hg commit -Am 2 adding f2 $ hg push pushing to ssh://user@dummy/server searching for changes remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files $ hg bookmark new-server-mark 2:0a76dfb2e179 $ cd ../server $ hg tglog o 2 [public:0a76dfb2e179] | o 1 [public:2b9c7234e035] | @ 0 [public:6cee5c8f3e5b]