##// END OF EJS Templates
wireprotov2: implement commands as a generator of objects...
wireprotov2: implement commands as a generator of objects Previously, wire protocol version 2 inherited version 1's model of having separate types to represent the results of different wire protocol commands. As I implemented more powerful commands in future commits, I found I was using a common pattern of returning a special type to hold a generator. This meant the command function required a closure to do most of the work. That made logic flow more difficult to follow. I also noticed that many commands were effectively a sequence of objects to be CBOR encoded. I think it makes sense to define version 2 commands as generators. This way, commands can simply emit the data structures they wish to send to the client. This eliminates the need for a closure in command functions and removes encoding from the bodies of commands. As part of this commit, the handling of response objects has been moved into the serverreactor class. This puts the reactor in the driver's seat with regards to CBOR encoding and error handling. Having error handling in the function that emits frames is particularly important because exceptions in that function can lead to things getting in a bad state: I'm fairly certain that uncaught exceptions in the frame generator were causing deadlocks. I also introduced a dedicated error type for explicit error reporting in command handlers. This will be used in subsequent commits. There's still a bit of work to be done here, especially around formalizing the error handling "protocol." I've added yet another TODO to track this so we don't forget. Test output changed because we're using generators and no longer know we are at the end of the data until we hit the end of the generator. This means we can't emit the end-of-stream flag until we've exhausted the generator. Hence the introduction of 0-sized end-of-stream frames. Differential Revision: https://phab.mercurial-scm.org/D4472

File last commit:

r39588:4c807ec0 default
r39595:07b58266 default
Show More
test-narrow-clone.t
280 lines | 6.1 KiB | text/troff | Tads3Lexer
/ tests / test-narrow-clone.t
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 $ . "$TESTDIR/narrow-library.sh"
$ hg init master
$ cd master
$ cat >> .hg/hgrc <<EOF
> [narrow]
> serveellipses=True
> EOF
$ 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 ../../..
Gregory Szorc
narrowspec: limit patterns to path: and rootfilesin: (BC)...
r39567 Only path: and rootfilesin: pattern prefixes are allowed
$ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --include 'glob:**'
abort: invalid prefix on narrow pattern: glob:**
(narrow patterns must begin with one of the following: path:, rootfilesin:)
[255]
$ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --exclude 'set:ignored'
abort: invalid prefix on narrow pattern: set:ignored
(narrow patterns must begin with one of the following: path:, rootfilesin:)
[255]
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 narrow clone a file, f10
$ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"
requesting all changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 1 changes to 1 files
new changesets *:* (glob)
$ cd narrow
$ cat .hg/requires | grep -v generaldelta
dotencode
fncache
Augie Fackler
narrowrepo: make repo requirement include the string 'experimental'...
r36106 narrowhg-experimental
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 revlogv1
store
Gregory Szorc
simplestore: use a custom store for the simple store repo...
r37433 testonly-simplestore (reposimplestore !)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Martin von Zweigbergk
tests: avoid unnecessarily looking inside .hg/ in test-narrow*...
r38873 $ hg tracked
I path:dir/src/f10
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 $ hg tracked
I path:dir/src/f10
$ hg update
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ find * | sort
dir
dir/src
dir/src/f10
$ cat dir/src/f10
10
$ cd ..
narrow clone with a newline should fail
$ hg clone --narrow ssh://user@dummy/master narrow_fail --noupdate --include 'dir/src/f10
> '
abort: newlines are not allowed in narrowspec paths
[255]
narrow clone a directory, tests/, except tests/t19
$ hg clone --narrow ssh://user@dummy/master narrowdir --noupdate --include "dir/tests/" --exclude "dir/tests/t19"
requesting all changes
adding changesets
adding manifests
adding file changes
added 21 changesets with 19 changes to 19 files
new changesets *:* (glob)
$ cd narrowdir
Martin von Zweigbergk
tests: avoid unnecessarily looking inside .hg/ in test-narrow*...
r38873 $ hg tracked
I path:dir/tests
X path:dir/tests/t19
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 $ hg tracked
I path:dir/tests
X path:dir/tests/t19
$ hg update
19 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ find * | sort
dir
dir/tests
dir/tests/t1
dir/tests/t10
dir/tests/t11
dir/tests/t12
dir/tests/t13
dir/tests/t14
dir/tests/t15
dir/tests/t16
dir/tests/t17
dir/tests/t18
dir/tests/t2
dir/tests/t20
dir/tests/t3
dir/tests/t4
dir/tests/t5
dir/tests/t6
dir/tests/t7
dir/tests/t8
dir/tests/t9
$ cd ..
narrow clone everything but a directory (tests/)
$ hg clone --narrow ssh://user@dummy/master narrowroot --noupdate --exclude "dir/tests"
requesting all changes
adding changesets
adding manifests
adding file changes
added 21 changesets with 20 changes to 20 files
new changesets *:* (glob)
$ cd narrowroot
Martin von Zweigbergk
tests: avoid unnecessarily looking inside .hg/ in test-narrow*...
r38873 $ hg tracked
I path:.
X path:dir/tests
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 $ hg tracked
I path:.
X path:dir/tests
$ hg update
20 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ find * | sort
dir
dir/src
dir/src/f1
dir/src/f10
dir/src/f11
dir/src/f12
dir/src/f13
dir/src/f14
dir/src/f15
dir/src/f16
dir/src/f17
dir/src/f18
dir/src/f19
dir/src/f2
dir/src/f20
dir/src/f3
dir/src/f4
dir/src/f5
dir/src/f6
dir/src/f7
dir/src/f8
dir/src/f9
$ cd ..
narrow clone no paths at all
$ hg clone --narrow ssh://user@dummy/master narrowempty --noupdate
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files
new changesets * (glob)
$ cd narrowempty
$ hg tracked
$ hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ ls
$ cd ..
simple clone
$ hg clone ssh://user@dummy/master simpleclone
requesting all changes
adding changesets
adding manifests
adding file changes
added 40 changesets with 40 changes to 40 files
new changesets * (glob)
updating to branch default
40 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd simpleclone
$ find * | sort
dir
dir/src
dir/src/f1
dir/src/f10
dir/src/f11
dir/src/f12
dir/src/f13
dir/src/f14
dir/src/f15
dir/src/f16
dir/src/f17
dir/src/f18
dir/src/f19
dir/src/f2
dir/src/f20
dir/src/f3
dir/src/f4
dir/src/f5
dir/src/f6
dir/src/f7
dir/src/f8
dir/src/f9
dir/tests
dir/tests/t1
dir/tests/t10
dir/tests/t11
dir/tests/t12
dir/tests/t13
dir/tests/t14
dir/tests/t15
dir/tests/t16
dir/tests/t17
dir/tests/t18
dir/tests/t19
dir/tests/t2
dir/tests/t20
dir/tests/t3
dir/tests/t4
dir/tests/t5
dir/tests/t6
dir/tests/t7
dir/tests/t8
dir/tests/t9
$ cd ..
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283
Testing the --narrowspec flag to clone
$ cat >> narrowspecs <<EOF
> %include foo
> [include]
> path:dir/tests/
Martin von Zweigbergk
tests: drop extra "file:" prefix from paths in narrow test...
r39578 > path:dir/src/f12
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 > EOF
$ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
reading narrowspec from '$TESTTMP/narrowspecs'
abort: cannot specify other files using '%include' in narrowspec
[255]
$ cat > narrowspecs <<EOF
> [include]
> path:dir/tests/
Martin von Zweigbergk
tests: drop extra "file:" prefix from paths in narrow test...
r39578 > path:dir/src/f12
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 > EOF
$ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
reading narrowspec from '$TESTTMP/narrowspecs'
requesting all changes
adding changesets
adding manifests
adding file changes
Martin von Zweigbergk
tests: drop extra "file:" prefix from paths in narrow test...
r39578 added 23 changesets with 21 changes to 21 files
new changesets c13e3773edb4:26ce255d5b5d
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 updating to branch default
Martin von Zweigbergk
tests: drop extra "file:" prefix from paths in narrow test...
r39578 21 files updated, 0 files merged, 0 files removed, 0 files unresolved
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 $ cd specfile
$ hg tracked
Martin von Zweigbergk
tests: drop extra "file:" prefix from paths in narrow test...
r39578 I path:dir/src/f12
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 I path:dir/tests
$ cd ..
Gregory Szorc
narrowspec: limit patterns to path: and rootfilesin: (BC)...
r39567
Narrow spec with invalid patterns is rejected
$ cat > narrowspecs <<EOF
> [include]
> glob:**
> EOF
$ hg clone ssh://user@dummy/master badspecfile --narrowspec narrowspecs
reading narrowspec from '$TESTTMP/narrowspecs'
abort: invalid prefix on narrow pattern: glob:**
(narrow patterns must begin with one of the following: path:, rootfilesin:)
[255]