diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -8,7 +8,7 @@ import urllib, tempfile, os, sys from i18n import _ from node import bin, hex -import changegroup as changegroupmod +import changegroup as changegroupmod, bundle2 import peer, error, encoding, util, store, exchange @@ -335,7 +335,10 @@ class wirepeer(peer.peerrepository): if bundlecaps is not None: opts['bundlecaps'] = ','.join(bundlecaps) f = self._callcompressable("getbundle", **opts) - return changegroupmod.unbundle10(f, 'UN') + if bundlecaps is not None and 'HG20' in bundlecaps: + return bundle2.unbundle20(self.ui, f) + else: + return changegroupmod.unbundle10(f, 'UN') def unbundle(self, cg, heads, source): '''Send cg (a readable file-like object representing the @@ -565,6 +568,8 @@ def _capabilities(repo, proto): # otherwise, add 'streamreqs' detailing our local revlog format else: caps.append('streamreqs=%s' % ','.join(requiredformats)) + if repo.ui.configbool('server', 'bundle2', False): + caps.append('bundle2') caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority)) caps.append('httpheader=1024') return caps @@ -602,7 +607,7 @@ def getbundle(repo, proto, others): opts[k] = decodelist(v) elif k == 'bundlecaps': opts[k] = set(v.split(',')) - cg = changegroupmod.getbundle(repo, 'serve', **opts) + cg = exchange.getbundle(repo, 'serve', **opts) return streamres(proto.groupchunks(cg)) @wireprotocommand('heads') diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t --- a/tests/test-bundle2.t +++ b/tests/test-bundle2.t @@ -156,6 +156,8 @@ Create an extension to test bundle2 API > bundle2=$TESTTMP/bundle2.py > [server] > bundle2=True + > [ui] + > ssh=python "$TESTDIR/dummyssh" > EOF The extension requires a repo (currently unused) @@ -682,3 +684,31 @@ push adding manifests adding file changes added 1 changesets with 0 changes to 0 files (-1 heads) + +pull over ssh + + $ hg -R other pull ssh://user@dummy/main -r 02de42196ebe --traceback + pulling from ssh://user@dummy/main + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files (+1 heads) + (run 'hg heads' to see heads, 'hg merge' to merge) + +pull over http + + $ hg -R main serve -p $HGPORT -d --pid-file=main.pid -E main-error.log + $ cat main.pid >> $DAEMON_PIDS + + $ hg -R other pull http://localhost:$HGPORT/ -r 42ccdea3bb16 + pulling from http://localhost:$HGPORT/ + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files (+1 heads) + (run 'hg heads .' to see heads, 'hg merge' to merge) + $ cat main-error.log + +