| 1 |
$ cat > bundle2.py << EOF |
| 2 |
> """A small extension to test bundle2 pushback parts. |
| 3 |
> Current bundle2 implementation doesn't provide a way to generate those |
| 4 |
> parts, so they must be created by extensions. |
| 5 |
> """ |
| 6 |
> from mercurial import bundle2_part_handlers as bundle2, exchange, pushkey, util |
| 7 |
> def _newhandlechangegroup(op, inpart): |
| 8 |
> """This function wraps the changegroup part handler for getbundle. |
| 9 |
> It issues an additional pushkey part to send a new |
| 10 |
> bookmark back to the client""" |
| 11 |
> result = bundle2.handlechangegroup(op, inpart) |
| 12 |
> if b'pushback' in op.reply.capabilities: |
| 13 |
> params = {b'namespace': b'bookmarks', |
| 14 |
> b'key': b'new-server-mark', |
| 15 |
> b'old': b'', |
| 16 |
> b'new': b'tip'} |
| 17 |
> encodedparams = [(k, pushkey.encode(v)) |
| 18 |
> for (k, v) in params.items()] |
| 19 |
> op.reply.newpart(b'pushkey', mandatoryparams=encodedparams) |
| 20 |
> else: |
| 21 |
> op.reply.newpart(b'output', data=b'pushback not enabled') |
| 22 |
> return result |
| 23 |
> _newhandlechangegroup.params = bundle2.handlechangegroup.params |
| 24 |
> bundle2.parthandlermapping[b'changegroup'] = _newhandlechangegroup |
| 25 |
> EOF |
| 26 |
|
| 27 |
$ cat >> $HGRCPATH <<EOF |
| 28 |
> [ui] |
| 29 |
> username = nobody <[email protected]> |
| 30 |
> |
| 31 |
> [alias] |
| 32 |
> tglog = log -G -T "{desc} [{phase}:{node|short}]" |
| 33 |
> EOF |
| 34 |
|
| 35 |
Set up server repository |
| 36 |
|
| 37 |
$ hg init server |
| 38 |
$ cd server |
| 39 |
$ echo c0 > f0 |
| 40 |
$ hg commit -Am 0 |
| 41 |
adding f0 |
| 42 |
|
| 43 |
Set up client repository |
| 44 |
|
| 45 |
$ cd .. |
| 46 |
$ hg clone ssh://user@dummy/server client -q |
| 47 |
$ cd client |
| 48 |
|
| 49 |
Enable extension |
| 50 |
$ cat >> $HGRCPATH <<EOF |
| 51 |
> [extensions] |
| 52 |
> bundle2=$TESTTMP/bundle2.py |
| 53 |
> EOF |
| 54 |
|
| 55 |
Without config |
| 56 |
|
| 57 |
$ cd ../client |
| 58 |
$ echo c1 > f1 |
| 59 |
$ hg commit -Am 1 |
| 60 |
adding f1 |
| 61 |
$ hg push |
| 62 |
pushing to ssh://user@dummy/server |
| 63 |
searching for changes |
| 64 |
remote: adding changesets |
| 65 |
remote: adding manifests |
| 66 |
remote: adding file changes |
| 67 |
remote: added 1 changesets with 1 changes to 1 files |
| 68 |
remote: pushback not enabled |
| 69 |
$ hg bookmark |
| 70 |
no bookmarks set |
| 71 |
|
| 72 |
$ cd ../server |
| 73 |
$ hg tglog |
| 74 |
o 1 [public:2b9c7234e035] |
| 75 |
| |
| 76 |
@ 0 [public:6cee5c8f3e5b] |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
With config |
| 82 |
|
| 83 |
$ cd ../client |
| 84 |
$ echo '[experimental]' >> .hg/hgrc |
| 85 |
$ echo 'bundle2.pushback = True' >> .hg/hgrc |
| 86 |
$ echo c2 > f2 |
| 87 |
$ hg commit -Am 2 |
| 88 |
adding f2 |
| 89 |
$ hg push |
| 90 |
pushing to ssh://user@dummy/server |
| 91 |
searching for changes |
| 92 |
remote: adding changesets |
| 93 |
remote: adding manifests |
| 94 |
remote: adding file changes |
| 95 |
remote: added 1 changesets with 1 changes to 1 files |
| 96 |
$ hg bookmark |
| 97 |
new-server-mark 2:0a76dfb2e179 |
| 98 |
|
| 99 |
$ cd ../server |
| 100 |
$ hg tglog |
| 101 |
o 2 [public:0a76dfb2e179] |
| 102 |
| |
| 103 |
o 1 [public:2b9c7234e035] |
| 104 |
| |
| 105 |
@ 0 [public:6cee5c8f3e5b] |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|