2014-11-22 02:50:38 +03:00
|
|
|
$ 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.
|
|
|
|
> """
|
2017-08-22 22:04:36 +03:00
|
|
|
> from __future__ import absolute_import
|
|
|
|
> from mercurial import bundle2, exchange, pushkey, util
|
2014-11-22 02:50:38 +03:00
|
|
|
> def _newhandlechangegroup(op, inpart):
|
|
|
|
> """This function wraps the changegroup part handler for getbundle.
|
2015-04-09 23:25:48 +03:00
|
|
|
> It issues an additional pushkey part to send a new
|
2014-11-22 02:50:38 +03:00
|
|
|
> bookmark back to the client"""
|
|
|
|
> result = bundle2.handlechangegroup(op, inpart)
|
2015-04-09 23:25:48 +03:00
|
|
|
> if 'pushback' in op.reply.capabilities:
|
2014-11-22 02:50:38 +03:00
|
|
|
> params = {'namespace': 'bookmarks',
|
|
|
|
> 'key': 'new-server-mark',
|
|
|
|
> 'old': '',
|
|
|
|
> 'new': 'tip'}
|
|
|
|
> encodedparams = [(k, pushkey.encode(v)) for (k,v) in params.items()]
|
2015-04-09 23:25:48 +03:00
|
|
|
> op.reply.newpart('pushkey', mandatoryparams=encodedparams)
|
2014-11-22 02:50:38 +03:00
|
|
|
> else:
|
2015-04-09 23:25:48 +03:00
|
|
|
> op.reply.newpart('output', data='pushback not enabled')
|
2014-11-22 02:50:38 +03:00
|
|
|
> return result
|
|
|
|
> _newhandlechangegroup.params = bundle2.handlechangegroup.params
|
2015-04-09 23:25:48 +03:00
|
|
|
> bundle2.parthandlermapping['changegroup'] = _newhandlechangegroup
|
2014-11-22 02:50:38 +03:00
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ cat >> $HGRCPATH <<EOF
|
|
|
|
> [ui]
|
2017-07-05 19:10:11 +03:00
|
|
|
> ssh = $PYTHON "$TESTDIR/dummyssh"
|
2014-11-22 02:50:38 +03:00
|
|
|
> username = nobody <no.reply@example.com>
|
|
|
|
> 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
|
2015-05-20 19:44:06 +03:00
|
|
|
remote: pushback not enabled
|
2014-11-22 02:50:38 +03:00
|
|
|
$ hg bookmark
|
|
|
|
no bookmarks set
|
|
|
|
|
|
|
|
$ cd ../server
|
2018-08-16 20:37:29 +03:00
|
|
|
$ tglogp
|
|
|
|
o 1: 2b9c7234e035 public '1'
|
2014-11-22 02:50:38 +03:00
|
|
|
|
|
2018-08-16 20:37:29 +03:00
|
|
|
@ 0: 6cee5c8f3e5b public '0'
|
2014-11-22 02:50:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2018-08-16 20:37:29 +03:00
|
|
|
$ tglogp
|
|
|
|
o 2: 0a76dfb2e179 public '2'
|
2014-11-22 02:50:38 +03:00
|
|
|
|
|
2018-08-16 20:37:29 +03:00
|
|
|
o 1: 2b9c7234e035 public '1'
|
2014-11-22 02:50:38 +03:00
|
|
|
|
|
2018-08-16 20:37:29 +03:00
|
|
|
@ 0: 6cee5c8f3e5b public '0'
|
2014-11-22 02:50:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|