diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -204,7 +204,7 @@ def _walkstreamfiles(repo): return repo.store.walk() -def generatev1(repo): +def generatev1(repo, includes=None, excludes=None): """Emit content for version 1 of a streaming clone. This returns a 3-tuple of (file count, byte size, data iterator). @@ -223,6 +223,10 @@ This function will obtain a repository lock to ensure a consistent view of the store is captured. It therefore may raise LockError. """ + if includes or excludes: + raise error.Abort("the server support for narrow stream clones is not" + " implemented yet") + entries = [] total_bytes = 0 # Get consistent snapshot of repo, lock during scan. @@ -256,7 +260,7 @@ return len(entries), total_bytes, emitrevlogdata() -def generatev1wireproto(repo): +def generatev1wireproto(repo, includes, excludes): """Emit content for version 1 of streaming clone suitable for the wire. This is the data output from ``generatev1()`` with 2 header lines. The @@ -272,7 +276,8 @@ return try: - filecount, bytecount, it = generatev1(repo) + filecount, bytecount, it = generatev1(repo, includes=includes, + excludes=excludes) except error.LockError: yield '2\n' return diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py --- a/mercurial/wireprotov1server.py +++ b/mercurial/wireprotov1server.py @@ -547,10 +547,10 @@ includes = None excludes = None if 'narrowstream' in _capabilities(repo, proto): - includes = args.get('includes') - excludes = args.get('excludes') + includes = wireprototypes.decodelist(args.get('includes')) + excludes = wireprototypes.decodelist(args.get('excludes')) return wireprototypes.streamreslegacy( - streamclone.generatev1wireproto(repo)) + streamclone.generatev1wireproto(repo, includes, excludes)) @wireprotocommand('unbundle', 'heads', permission='push') def unbundle(repo, proto, heads): diff --git a/tests/test-narrow-clone-stream.t b/tests/test-narrow-clone-stream.t new file mode 100644 --- /dev/null +++ b/tests/test-narrow-clone-stream.t @@ -0,0 +1,43 @@ +Tests the support of serving narrow-stream clones with stream clone v1 + + $ . "$TESTDIR/narrow-library.sh" + +Server setup + + $ hg init master + $ cd master + $ echo "[server]" >> .hg/hgrc + $ echo "bundle2.stream=False" >> .hg/hgrc + $ mkdir dir + $ mkdir dir/src + $ cd dir/src + $ for x in `$TESTDIR/seq.py 20`; do echo $x > "f$x"; hg add "f$x"; hg commit -m "Commit src $x"; done + $ cd .. + $ mkdir tests + $ cd tests + $ for x in `$TESTDIR/seq.py 20`; do echo $x > "t$x"; hg add "t$x"; hg commit -m "Commit test $x"; done + $ cd ../../.. + +Trying to stream clone when the server does not support it + + $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10" --stream + streaming all changes + server does not support narrow stream clones, cloning full repository + 42 files to transfer, 13.2 KB of data + transferred 13.2 KB in * seconds (* KB/sec) (glob) + searching for changes + no changes found + +Enable stream clone on server + + $ cd master + $ echo "stream-narrow-clones=True" >> .hg/hgrc + $ cd .. + +Cloning a specific file when stream clone is supported + + $ hg clone --narrow ssh://user@dummy/master realnarrow --noupdate --include "dir/src/f10" --stream + streaming all changes + remote: abort: the server support for narrow stream clones is not implemented yet + abort: unexpected response from remote server: empty string + [255]