##// END OF EJS Templates
httppeer: implement command executor for version 2 peer...
httppeer: implement command executor for version 2 peer Now that we have a new API for issuing commands which is compatible with wire protocol version 2, we can start using it with wire protocol version 2. This commit replaces our hacky implementation of _call() with something a bit more robust based on the new command executor interface. We now have proper support for issuing multiple commands per HTTP request. Each HTTP request maintains its own client reactor. The implementation is similar to the one in the legacy wire protocol. We use a ThreadPoolExecutor for spinning up a thread to read the HTTP response in the background. This allows responses to resolve in any order. While not implemented on the server yet, a client could use concurrent.futures.as_completed() with a collection of futures and handle responses as they arrive from the server. The return value from issued commands is still a simple list of raw or decoded CBOR data. This is still super hacky. We will want a rich data type for representing command responses. But at least this commit gets us one step closer to a proper peer implementation. Differential Revision: https://phab.mercurial-scm.org/D3297

File last commit:

r36069:af9cb761 default
r37669:950294e2 default
Show More
test-encoding-align.t
150 lines | 5.2 KiB | text/troff | Tads3Lexer
/ tests / test-encoding-align.t
Matt Mackall
tests: unify test-encoding-align
r12418 Test alignment of multibyte characters
$ HGENCODING=utf-8
$ export HGENCODING
$ hg init t
$ cd t
Augie Fackler
tests: replace yet more calls to `python` with $PYTHON...
r33262 $ $PYTHON << EOF
Matt Mackall
tests: unify test-encoding-align
r12418 > # (byte, width) = (6, 4)
Pulkit Goyal
py3: replace file() with open() in test-encoding-align.t...
r36069 > s = b"\xe7\x9f\xad\xe5\x90\x8d"
Matt Mackall
tests: unify test-encoding-align
r12418 > # (byte, width) = (7, 7): odd width is good for alignment test
Pulkit Goyal
py3: replace file() with open() in test-encoding-align.t...
r36069 > m = b"MIDDLE_"
Matt Mackall
tests: unify test-encoding-align
r12418 > # (byte, width) = (18, 12)
Pulkit Goyal
py3: replace file() with open() in test-encoding-align.t...
r36069 > l = b"\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d"
> f = open('s', 'wb'); f.write(s); f.close()
> f = open('m', 'wb'); f.write(m); f.close()
> f = open('l', 'wb'); f.write(l); f.close()
Matt Mackall
tests: unify test-encoding-align
r12418 > # instant extension to show list of options
Pulkit Goyal
py3: replace file() with open() in test-encoding-align.t...
r36069 > f = open('showoptlist.py', 'wb'); f.write(b"""# encoding: utf-8
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 > from mercurial import registrar
Gregory Szorc
tests: declare commands using decorator
r21254 > cmdtable = {}
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 > command = registrar.command(cmdtable)
Gregory Szorc
tests: declare commands using decorator
r21254 >
Pulkit Goyal
py3: make sure commands name are bytes in tests
r33097 > @command(b'showoptlist',
Gregory Szorc
tests: declare commands using decorator
r21254 > [('s', 'opt1', '', 'short width' + ' %(s)s' * 8, '%(s)s'),
> ('m', 'opt2', '', 'middle width' + ' %(m)s' * 8, '%(m)s'),
> ('l', 'opt3', '', 'long width' + ' %(l)s' * 8, '%(l)s')],
> '')
Matt Mackall
tests: unify test-encoding-align
r12418 > def showoptlist(ui, repo, *pats, **opts):
> '''dummy command to show option descriptions'''
> return 0
Mads Kiilerich
util: wrap lines with multi-byte characters correctly (issue2943)...
r15031 > """ % globals())
Matt Mackall
tests: unify test-encoding-align
r12418 > f.close()
> EOF
$ S=`cat s`
$ M=`cat m`
$ L=`cat l`
alignment of option descriptions in help
$ cat <<EOF > .hg/hgrc
> [extensions]
> ja_ext = `pwd`/showoptlist.py
> EOF
check alignment of option descriptions in help
$ hg help showoptlist
Matt Mackall
help: generate command help into a single RST string for formatting
r15203 hg showoptlist
Matt Mackall
tests: unify test-encoding-align
r12418
dummy command to show option descriptions
options:
Matt Mackall
help: use RST to format option lists
r15145 -s --opt1 \xe7\x9f\xad\xe5\x90\x8d short width \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d (esc)
-m --opt2 MIDDLE_ middle width MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_
MIDDLE_ MIDDLE_ MIDDLE_
-l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d long width \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
Matt Mackall
tests: unify test-encoding-align
r12418
Matt Mackall
help: tweak --verbose command help hint...
r22110 (some details hidden, use --verbose to show complete help)
Matt Mackall
tests: unify test-encoding-align
r12418
$ rm -f s; touch s
$ rm -f m; touch m
$ rm -f l; touch l
add files
$ cp s $S
$ hg add $S
$ cp m $M
$ hg add $M
$ cp l $L
$ hg add $L
commit(1)
$ echo 'first line(1)' >> s; cp s $S
$ echo 'first line(2)' >> m; cp m $M
$ echo 'first line(3)' >> l; cp l $L
$ hg commit -m 'first commit' -u $S
commit(2)
$ echo 'second line(1)' >> s; cp s $S
$ echo 'second line(2)' >> m; cp m $M
$ echo 'second line(3)' >> l; cp l $L
$ hg commit -m 'second commit' -u $M
commit(3)
$ echo 'third line(1)' >> s; cp s $S
$ echo 'third line(2)' >> m; cp m $M
$ echo 'third line(3)' >> l; cp l $L
$ hg commit -m 'third commit' -u $L
check alignment of user names in annotate
$ hg annotate -u $M
Mads Kiilerich
tests: use (esc) markup for string-escape...
r12941 \xe7\x9f\xad\xe5\x90\x8d: first line(2) (esc)
Matt Mackall
tests: unify test-encoding-align
r12418 MIDDLE_: second line(2)
Mads Kiilerich
tests: use (esc) markup for string-escape...
r12941 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d: third line(2) (esc)
Matt Mackall
tests: unify test-encoding-align
r12418
check alignment of filenames in diffstat
$ hg diff -c tip --stat
MIDDLE_ | 1 +
Mads Kiilerich
tests: use (esc) markup for string-escape...
r12941 \xe7\x9f\xad\xe5\x90\x8d | 1 + (esc)
\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d | 1 + (esc)
Matt Mackall
tests: unify test-encoding-align
r12418 3 files changed, 3 insertions(+), 0 deletions(-)
add branches/tags
$ hg branch $S
Mads Kiilerich
tests: use (esc) markup for string-escape...
r12941 marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d (esc)
Matt Mackall
branch: warn on branching
r15615 (branches are permanent and global, did you want a bookmark?)
Matt Mackall
tests: unify test-encoding-align
r12418 $ hg tag $S
Matt Mackall
bookmarks: properly align multi-byte characters
r21571 $ hg book -f $S
Matt Mackall
tests: unify test-encoding-align
r12418 $ hg branch $M
marked working directory as branch MIDDLE_
$ hg tag $M
Matt Mackall
bookmarks: properly align multi-byte characters
r21571 $ hg book -f $M
Matt Mackall
tests: unify test-encoding-align
r12418 $ hg branch $L
Mads Kiilerich
tests: use (esc) markup for string-escape...
r12941 marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc)
Matt Mackall
tests: unify test-encoding-align
r12418 $ hg tag $L
Matt Mackall
bookmarks: properly align multi-byte characters
r21571 $ hg book -f $L
Matt Mackall
tests: unify test-encoding-align
r12418
check alignment of branches
Matt Mackall
tests: fix cut and paste error on encoding alignment test
r21570 $ hg branches
\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 5:d745ff46155b (esc)
MIDDLE_ 4:9259be597f19 (inactive)
\xe7\x9f\xad\xe5\x90\x8d 3:b06c5b6def9e (inactive) (esc)
default 2:64a70663cee8 (inactive)
Matt Mackall
tests: unify test-encoding-align
r12418
check alignment of tags
$ hg tags
tip 5:d745ff46155b
Mads Kiilerich
tests: use (esc) markup for string-escape...
r12941 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 4:9259be597f19 (esc)
Matt Mackall
tests: unify test-encoding-align
r12418 MIDDLE_ 3:b06c5b6def9e
Mads Kiilerich
tests: use (esc) markup for string-escape...
r12941 \xe7\x9f\xad\xe5\x90\x8d 2:64a70663cee8 (esc)
Mads Kiilerich
tests: add missing trailing 'cd ..'...
r16913
Matt Mackall
bookmarks: properly align multi-byte characters
r21571 check alignment of bookmarks
$ hg book
MIDDLE_ 5:d745ff46155b
\xe7\x9f\xad\xe5\x90\x8d 4:9259be597f19 (esc)
* \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 5:d745ff46155b (esc)