annotate tests/test-chg.t @ 51861:f81e0ce5103a default tip

typing: simplify archive.gz writing and drop a few pytype suppressions I was waiting until 3.8 to use `Literal` to fix this, but there's also the ":" and "|" characters that are passed along here, meant only for the non-gz archive types. But manipulating what the local caller passes is silly- we know we're writing, so just open it for writing. As an added bonus, PyCharm stops flagging the call too (since it doesn't know about pytype suppression comments).
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 12 Sep 2024 12:53:00 -0400
parents 8b77ad54d67a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29274
148a9a5379f0 test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents: 29088
diff changeset
1 #require chg
148a9a5379f0 test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents: 29088
diff changeset
2
49784
e45590649888 chg: scale the timeout in test with the rest
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49420
diff changeset
3 Scale the timeout for the chg-server to the test timeout scaling.
e45590649888 chg: scale the timeout in test with the rest
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49420
diff changeset
4 This is done to reduce the flakiness of this test on heavy load.
e45590649888 chg: scale the timeout in test with the rest
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49420
diff changeset
5
e45590649888 chg: scale the timeout in test with the rest
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49420
diff changeset
6 $ CHGTIMEOUT=`expr $HGTEST_TIMEOUT / 6`
e45590649888 chg: scale the timeout in test with the rest
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49420
diff changeset
7 $ export CHGTIMEOUT
e45590649888 chg: scale the timeout in test with the rest
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49420
diff changeset
8
40827
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
9 $ mkdir log
40999
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
10 $ cp $HGRCPATH $HGRCPATH.unconfigured
40826
1617aa916d88 commandserver: expand log path for convenience
Yuya Nishihara <yuya@tcha.org>
parents: 40825
diff changeset
11 $ cat <<'EOF' >> $HGRCPATH
40825
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
12 > [cmdserver]
40827
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
13 > log = $TESTTMP/log/server.log
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
14 > max-log-files = 1
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
15 > max-log-size = 10 kB
40825
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
16 > EOF
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
17 $ cp $HGRCPATH $HGRCPATH.orig
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
18
40825
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
19 $ filterlog () {
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
20 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
21 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
22 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \
40999
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
23 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \
40825
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
24 > -e 's!\(pid\)=[0-9]*!\1=...!g' \
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
25 > -e 's!\(/server-\)[0-9a-f]*!\1...!g'
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
26 > }
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
27
28516
3bf2892f685f chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff changeset
28 init repo
3bf2892f685f chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff changeset
29
29274
148a9a5379f0 test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents: 29088
diff changeset
30 $ chg init foo
28516
3bf2892f685f chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff changeset
31 $ cd foo
3bf2892f685f chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff changeset
32
3bf2892f685f chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff changeset
33 ill-formed config
3bf2892f685f chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff changeset
34
29274
148a9a5379f0 test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents: 29088
diff changeset
35 $ chg status
28516
3bf2892f685f chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff changeset
36 $ echo '=brokenconfig' >> $HGRCPATH
29274
148a9a5379f0 test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents: 29088
diff changeset
37 $ chg status
45988
c6da62004c0f tests: update test-chg.t with output change
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45520
diff changeset
38 config error at * =brokenconfig (glob)
46145
6383bb86b700 chgserver: respect detailed exit code in case of ConfigError
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45988
diff changeset
39 [30]
29088
983353035cec chgserver: remove _clearenvaliases
Jun Wu <quark@fb.com>
parents: 28516
diff changeset
40
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
41 $ cp $HGRCPATH.orig $HGRCPATH
30677
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
42
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
43 long socket path
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
44
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
45 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
46 $ mkdir -p $sockpath
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
47 $ bakchgsockname=$CHGSOCKNAME
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
48 $ CHGSOCKNAME=$sockpath/server
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
49 $ export CHGSOCKNAME
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
50 $ chg root
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
51 $TESTTMP/foo
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
52 $ rm -rf $sockpath
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
53 $ CHGSOCKNAME=$bakchgsockname
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
54 $ export CHGSOCKNAME
c80c16a8a0b0 chg: support long socket path
Jun Wu <quark@fb.com>
parents: 30620
diff changeset
55
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
56 $ cd ..
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
57
31107
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
58 editor
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
59 ------
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
60
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
61 $ cat >> pushbuffer.py <<EOF
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
62 > def reposetup(ui, repo):
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
63 > repo.ui.pushbuffer(subproc=True)
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
64 > EOF
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
65
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
66 $ chg init editor
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
67 $ cd editor
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
68
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
69 by default, system() should be redirected to the client:
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
70
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
71 $ touch foo
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
72 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
50725
7e5be4a7cda7 tests: use grep -E instead of obsolescent egrep
Mads Kiilerich <mads@kiilerich.com>
parents: 50353
diff changeset
73 > | grep -E "HG:|run 'cat"
34309
b94db1780365 chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents: 33949
diff changeset
74 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob)
31107
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
75 HG: Enter commit message. Lines beginning with 'HG:' are removed.
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
76 HG: Leave message empty to abort commit.
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
77 HG: --
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
78 HG: user: test
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
79 HG: branch 'default'
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
80 HG: added foo
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
81
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
82 but no redirection should be made if output is captured:
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
83
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
84 $ touch bar
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
85 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
86 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
50725
7e5be4a7cda7 tests: use grep -E instead of obsolescent egrep
Mads Kiilerich <mads@kiilerich.com>
parents: 50353
diff changeset
87 > | grep -E "HG:|run 'cat"
31107
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
88 [1]
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
89
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
90 check that commit commands succeeded:
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
91
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
92 $ hg log -T '{rev}:{desc}\n'
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
93 1:bufferred
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
94 0:channeled
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
95
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
96 $ cd ..
fbce78c58f1e chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents: 30847
diff changeset
97
30847
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
98 pager
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
99 -----
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
100
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
101 $ cat >> fakepager.py <<EOF
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
102 > import sys
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
103 > for line in sys.stdin:
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
104 > sys.stdout.write('paged! %r\n' % line)
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
105 > EOF
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
106
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
107 enable pager extension globally, but spawns the master server with no tty:
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
108
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
109 $ chg init pager
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
110 $ cd pager
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
111 $ cat >> $HGRCPATH <<EOF
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
112 > [extensions]
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
113 > pager =
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
114 > [pager]
39707
5abc47d4ca6b tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents: 34309
diff changeset
115 > pager = "$PYTHON" $TESTTMP/fakepager.py
30847
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
116 > EOF
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
117 $ chg version > /dev/null
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
118 $ touch foo
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
119 $ chg ci -qAm foo
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
120
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
121 pager should be enabled if the attached client has a tty:
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
122
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
123 $ chg log -l1 -q --config ui.formatted=True
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
124 paged! '0:1f7b0de80e11\n'
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
125 $ chg log -l1 -q --config ui.formatted=False
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
126 0:1f7b0de80e11
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
127
31890
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
128 chg waits for pager if runcommand raises
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
129
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
130 $ cat > $TESTTMP/crash.py <<EOF
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 31890
diff changeset
131 > from mercurial import registrar
31890
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
132 > cmdtable = {}
32337
46ba2cdda476 registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents: 31890
diff changeset
133 > command = registrar.command(cmdtable)
33097
fce4ed2912bb py3: make sure commands name are bytes in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32940
diff changeset
134 > @command(b'crash')
31890
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
135 > def pagercrash(ui, repo, *pats, **opts):
43154
f05d10ef42e3 py3: add a missing b'' prefix in test extension for chg
Martin von Zweigbergk <martinvonz@google.com>
parents: 40999
diff changeset
136 > ui.write(b'going to crash\n')
31890
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
137 > raise Exception('.')
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
138 > EOF
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
139
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
140 $ cat > $TESTTMP/fakepager.py <<EOF
33949
0d0cec9602c3 tests: update test-chg to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33097
diff changeset
141 > import sys
0d0cec9602c3 tests: update test-chg to pass our import checker
Augie Fackler <raf@durin42.com>
parents: 33097
diff changeset
142 > import time
31890
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
143 > for line in iter(sys.stdin.readline, ''):
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
144 > if 'crash' in line: # only interested in lines containing 'crash'
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
145 > # if chg exits when pager is sleeping (incorrectly), the output
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
146 > # will be captured by the next test case
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
147 > time.sleep(1)
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
148 > sys.stdout.write('crash-pager: %s' % line)
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
149 > EOF
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
150
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
151 $ cat >> .hg/hgrc <<EOF
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
152 > [extensions]
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
153 > crash = $TESTTMP/crash.py
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
154 > EOF
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
155
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
156 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
157 crash-pager: going to crash
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
158 [255]
ca7af5d15b21 chg: always wait for pager
Jun Wu <quark@fb.com>
parents: 31107
diff changeset
159
45185
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
160 no stdout data should be printed after pager quits, and the buffered data
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
161 should never persist (issue6207)
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
162
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
163 "killed!" may be printed if terminated by SIGPIPE, which isn't important
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
164 in this test.
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
165
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
166 $ cat > $TESTTMP/bulkwrite.py <<'EOF'
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
167 > import time
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
168 > from mercurial import error, registrar
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
169 > cmdtable = {}
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
170 > command = registrar.command(cmdtable)
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
171 > @command(b'bulkwrite')
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
172 > def bulkwrite(ui, repo, *pats, **opts):
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
173 > ui.write(b'going to write massive data\n')
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
174 > ui.flush()
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
175 > t = time.time()
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
176 > while time.time() - t < 2:
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
177 > ui.write(b'x' * 1023 + b'\n') # will be interrupted by SIGPIPE
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
178 > raise error.Abort(b"write() doesn't block")
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
179 > EOF
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
180
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
181 $ cat > $TESTTMP/fakepager.py <<'EOF'
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
182 > import sys
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
183 > import time
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
184 > sys.stdout.write('paged! %r\n' % sys.stdin.readline())
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
185 > time.sleep(1) # new data will be written
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
186 > EOF
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
187
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
188 $ cat >> .hg/hgrc <<EOF
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
189 > [extensions]
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
190 > bulkwrite = $TESTTMP/bulkwrite.py
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
191 > EOF
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
192
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
193 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
194 paged! 'going to write massive data\n'
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
195 killed! (?)
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
196 [255]
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
197
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
198 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
199 paged! 'going to write massive data\n'
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
200 killed! (?)
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
201 [255]
a17454a189d1 chgserver: discard buffered output before restoring fds (issue6207)
Yuya Nishihara <yuya@tcha.org>
parents: 44990
diff changeset
202
30847
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
203 $ cd ..
e12553cfd0a4 pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents: 30677
diff changeset
204
45520
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
205 missing stdio
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
206 -------------
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
207
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
208 $ CHGDEBUG=1 chg version -q 0<&-
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
209 chg: debug: * stdio fds are missing (glob)
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
210 chg: debug: * execute original hg (glob)
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
211 Mercurial Distributed SCM * (glob)
5eee6f4f3d0d chg: fallback to original hg if stdio fds are missing
Jun Wu <quark@fb.com>
parents: 45188
diff changeset
212
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
213 server lifecycle
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
214 ----------------
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
215
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
216 chg server should be restarted on code change, and old server will shut down
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
217 automatically. In this test, we use the following time parameters:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
218
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
219 - "sleep 1" to make mtime different
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
220 - "sleep 2" to notice mtime change (polling interval is 1 sec)
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
221
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
222 set up repository with an extension:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
223
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
224 $ chg init extreload
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
225 $ cd extreload
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
226 $ touch dummyext.py
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
227 $ cat <<EOF >> .hg/hgrc
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
228 > [extensions]
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
229 > dummyext = dummyext.py
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
230 > EOF
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
231
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
232 isolate socket directory for stable result:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
233
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
234 $ OLDCHGSOCKNAME=$CHGSOCKNAME
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
235 $ mkdir chgsock
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
236 $ CHGSOCKNAME=`pwd`/chgsock/server
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
237
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
238 warm up server:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
239
50725
7e5be4a7cda7 tests: use grep -E instead of obsolescent egrep
Mads Kiilerich <mads@kiilerich.com>
parents: 50353
diff changeset
240 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
34309
b94db1780365 chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents: 33949
diff changeset
241 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
242
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
243 new server should be started if extension modified:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
244
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
245 $ sleep 1
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
246 $ touch dummyext.py
50725
7e5be4a7cda7 tests: use grep -E instead of obsolescent egrep
Mads Kiilerich <mads@kiilerich.com>
parents: 50353
diff changeset
247 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
34309
b94db1780365 chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents: 33949
diff changeset
248 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
b94db1780365 chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents: 33949
diff changeset
249 chg: debug: * instruction: reconnect (glob)
b94db1780365 chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents: 33949
diff changeset
250 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
251
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
252 old server will shut down, while new server should still be reachable:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
253
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
254 $ sleep 2
50725
7e5be4a7cda7 tests: use grep -E instead of obsolescent egrep
Mads Kiilerich <mads@kiilerich.com>
parents: 50353
diff changeset
255 $ CHGDEBUG= chg log 2>&1 | (grep -E 'instruction|start' || true)
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
256
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
257 socket file should never be unlinked by old server:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
258 (simulates unowned socket by updating mtime, which makes sure server exits
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
259 at polling cycle)
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
260
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
261 $ ls chgsock/server-*
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
262 chgsock/server-* (glob)
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
263 $ touch chgsock/server-*
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
264 $ sleep 2
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
265 $ ls chgsock/server-*
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
266 chgsock/server-* (glob)
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
267
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
268 since no server is reachable from socket file, new server should be started:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
269 (this test makes sure that old server shut down automatically)
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
270
50725
7e5be4a7cda7 tests: use grep -E instead of obsolescent egrep
Mads Kiilerich <mads@kiilerich.com>
parents: 50353
diff changeset
271 $ CHGDEBUG= chg log 2>&1 | grep -E 'instruction|start'
34309
b94db1780365 chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents: 33949
diff changeset
272 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
273
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
274 shut down servers and restore environment:
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
276 $ rm -R chgsock
40825
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
277 $ sleep 2
29275
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
278 $ CHGSOCKNAME=$OLDCHGSOCKNAME
e53f961ac75f test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents: 29274
diff changeset
279 $ cd ..
40825
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
280
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
281 check that server events are recorded:
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
282
40827
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
283 $ ls log
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
284 server.log
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
285 server.log.1
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
286
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
287 print only the last 10 lines, since we aren't sure how many records are
44990
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44359
diff changeset
288 preserved (since setprocname isn't available on py3 and pure version,
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44359
diff changeset
289 the 10th-most-recent line is different when using py3):
40827
d23fd01cc115 commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents: 40826
diff changeset
290
51499
8b77ad54d67a test-chg: stabilize the log checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51389
diff changeset
291 (the "worker process exited" line is matched independently as it order is unstable with the "exiting" line, the worker might exit before the server decide to exit).
8b77ad54d67a test-chg: stabilize the log checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51389
diff changeset
292
8b77ad54d67a test-chg: stabilize the log checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51389
diff changeset
293 $ cat log/server.log.1 log/server.log | tail -10 | grep -v "worker process exited" | filterlog
44990
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44359
diff changeset
294 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (no-setprocname !)
40999
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
295 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
44990
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44359
diff changeset
296 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (setprocname !)
40825
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
297 YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
298 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
299 YYYY/MM/DD HH:MM:SS (PID)> setumask 18
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
300 YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
301 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
eaabcb689747 commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents: 39707
diff changeset
302 YYYY/MM/DD HH:MM:SS (PID)> validate: []
51499
8b77ad54d67a test-chg: stabilize the log checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51389
diff changeset
303 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
8b77ad54d67a test-chg: stabilize the log checking
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51389
diff changeset
304 $ cat log/server.log.1 log/server.log | tail -10 | grep "worker process exited" | filterlog
40828
25e9089c7686 commandserver: turn server debug messages into logs
Yuya Nishihara <yuya@tcha.org>
parents: 40827
diff changeset
305 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
40999
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
306
44325
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
307 global data mutated by schems
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
308 -----------------------------
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
309
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
310 $ hg init schemes
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
311 $ cd schemes
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
312
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
313 initial state
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
314
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
315 $ cat > .hg/hgrc <<'EOF'
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
316 > [extensions]
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
317 > schemes =
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
318 > [schemes]
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
319 > foo = https://foo.example.org/
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
320 > EOF
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
321 $ hg debugexpandscheme foo://expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
322 https://foo.example.org/expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
323 $ hg debugexpandscheme bar://unexpanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
324 bar://unexpanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
325
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
326 add bar
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
327
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
328 $ cat > .hg/hgrc <<'EOF'
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
329 > [extensions]
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
330 > schemes =
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
331 > [schemes]
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
332 > foo = https://foo.example.org/
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
333 > bar = https://bar.example.org/
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
334 > EOF
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
335 $ hg debugexpandscheme foo://expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
336 https://foo.example.org/expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
337 $ hg debugexpandscheme bar://expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
338 https://bar.example.org/expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
339
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
340 remove foo
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
341
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
342 $ cat > .hg/hgrc <<'EOF'
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
343 > [extensions]
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
344 > schemes =
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
345 > [schemes]
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
346 > bar = https://bar.example.org/
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
347 > EOF
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
348 $ hg debugexpandscheme foo://unexpanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
349 foo://unexpanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
350 $ hg debugexpandscheme bar://expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
351 https://bar.example.org/expanded
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
352
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
353 $ cd ..
5cd2d91eeebd chgserver: spawn new process if schemes change
Yuya Nishihara <yuya@tcha.org>
parents: 43860
diff changeset
354
40999
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
355 repository cache
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
356 ----------------
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
357
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
358 $ cp $HGRCPATH.unconfigured $HGRCPATH
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
359 $ cat <<'EOF' >> $HGRCPATH
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
360 > [cmdserver]
50098
889d2a2e9326 test-chg: use a different log to avoid flakyness
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49784
diff changeset
361 > log = $TESTTMP/log/server-cached.log
40999
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
362 > max-repo-cache = 1
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
363 > track-log = command, repocache
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
364 > EOF
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
365
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
366 isolate socket directory for stable result:
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
367
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
368 $ OLDCHGSOCKNAME=$CHGSOCKNAME
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
369 $ mkdir chgsock
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
370 $ CHGSOCKNAME=`pwd`/chgsock/server
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
371
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
372 create empty repo and cache it:
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
373
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
374 $ hg init cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
375 $ hg id -R cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
376 000000000000 tip
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
377 $ sleep 1
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
378
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
379 modify repo (and cache will be invalidated):
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
380
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
381 $ touch cached/a
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
382 $ hg ci -R cached -Am 'add a'
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
383 adding a
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
384 $ sleep 1
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
385
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
386 read cached repo:
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
387
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
388 $ hg log -R cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
389 changeset: 0:ac82d8b1f7c4
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
390 tag: tip
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
391 user: test
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
392 date: Thu Jan 01 00:00:00 1970 +0000
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
393 summary: add a
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
394
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
395 $ sleep 1
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
396
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
397 discard cached from LRU cache:
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
398
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
399 $ hg clone cached cached2
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
400 updating to branch default
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
401 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
402 $ hg id -R cached2
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
403 ac82d8b1f7c4 tip
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
404 $ sleep 1
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
405
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
406 read uncached repo:
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
407
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
408 $ hg log -R cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
409 changeset: 0:ac82d8b1f7c4
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
410 tag: tip
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
411 user: test
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
412 date: Thu Jan 01 00:00:00 1970 +0000
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
413 summary: add a
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
414
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
415 $ sleep 1
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
416
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
417 shut down servers and restore environment:
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
418
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
419 $ rm -R chgsock
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
420 $ sleep 2
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
421 $ CHGSOCKNAME=$OLDCHGSOCKNAME
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
422
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
423 check server log:
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
424
50098
889d2a2e9326 test-chg: use a different log to avoid flakyness
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49784
diff changeset
425 $ cat log/server-cached.log | filterlog
40999
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
426 YYYY/MM/DD HH:MM:SS (PID)> init cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
427 YYYY/MM/DD HH:MM:SS (PID)> id -R cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
428 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
429 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
430 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a'
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
431 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
432 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
433 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
434 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
435 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
436 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
437 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s)
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
438 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
dcac24ec935b commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents: 40998
diff changeset
439 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
43860
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
440
49420
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
441 Test that -R is interpreted relative to --cwd.
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
442
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
443 $ hg init repo1
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
444 $ mkdir -p a/b
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
445 $ hg init a/b/repo2
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
446 $ printf "[alias]\ntest=repo1\n" >> repo1/.hg/hgrc
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
447 $ printf "[alias]\ntest=repo2\n" >> a/b/repo2/.hg/hgrc
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
448 $ cd a
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
449 $ chg --cwd .. -R repo1 show alias.test
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
450 repo1
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
451 $ chg --cwd . -R b/repo2 show alias.test
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
452 repo2
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
453 $ cd ..
3681a47611b8 dispatch: change cwd when loading local config
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 48876
diff changeset
454
44261
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
455 Test that chg works (sets to the user's actual LC_CTYPE) even when python
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
456 "coerces" the locale (py3.7+)
43860
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
457
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
458 $ cat > $TESTTMP/debugenv.py <<EOF
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
459 > from mercurial import encoding
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
460 > from mercurial import registrar
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
461 > cmdtable = {}
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
462 > command = registrar.command(cmdtable)
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
463 > @command(b'debugenv', [], b'', norepo=True)
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
464 > def debugenv(ui):
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
465 > for k in [b'LC_ALL', b'LC_CTYPE', b'LANG']:
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
466 > v = encoding.environ.get(k)
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
467 > if v is not None:
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
468 > ui.write(b'%s=%s\n' % (k, encoding.environ[k]))
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
469 > EOF
44261
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
470 (hg keeps python's modified LC_CTYPE, chg doesn't)
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
471 $ (unset LC_ALL; unset LANG; LC_CTYPE= "$CHGHG" \
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
472 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
473 LC_CTYPE=C.UTF-8 (py37 !)
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
474 LC_CTYPE= (no-py37 !)
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
475 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
476 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
477 LC_CTYPE=
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
478 $ (unset LC_ALL; unset LANG; LC_CTYPE=unsupported_value chg \
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
479 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
47022
ec081d7f0009 tests: fix test-chg to ignore a warning about being unable to set locale
Kyle Lippincott <spectral@google.com>
parents: 46145
diff changeset
480 *cannot change locale* (glob) (?)
44261
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
481 LC_CTYPE=unsupported_value
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
482 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
483 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
484 LC_CTYPE=
43860
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
485 $ LANG= LC_ALL= LC_CTYPE= chg \
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
486 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
487 LC_ALL=
44261
04a3ae7aba14 chg: force-set LC_CTYPE on server start to actual value from the environment
Kyle Lippincott <spectral@google.com>
parents: 43860
diff changeset
488 LC_CTYPE=
43860
5e0f6451e2d2 chg: fix chg to work with py3.7+ "coercing" the locale
Kyle Lippincott <spectral@google.com>
parents: 43800
diff changeset
489 LANG=
47023
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
490
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
491 Profiling isn't permanently enabled or carried over between chg invocations that
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
492 share the same server
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
493 $ cp $HGRCPATH.orig $HGRCPATH
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
494 $ hg init $TESTTMP/profiling
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
495 $ cd $TESTTMP/profiling
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
496 $ filteredchg() {
48275
1ea289e34c70 tests: better determinism in test-chg.t
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 47024
diff changeset
497 > CHGDEBUG=1 chg "$@" 2>&1 | sed -rn 's_^No samples recorded.*$_Sample count: 0_; /Sample count/p; /start cmdserver/p'
47023
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
498 > }
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
499 $ newchg() {
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
500 > chg --kill-chg-daemon
50725
7e5be4a7cda7 tests: use grep -E instead of obsolescent egrep
Mads Kiilerich <mads@kiilerich.com>
parents: 50353
diff changeset
501 > filteredchg "$@" | grep -E -v 'start cmdserver' || true
47023
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
502 > }
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
503 (--profile isn't permanently on just because it was specified when chg was
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
504 started)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
505 $ newchg log -r . --profile
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
506 Sample count: * (glob)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
507 $ filteredchg log -r .
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
508 (enabling profiling via config works, even on the first chg command that starts
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
509 a cmdserver)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
510 $ cat >> $HGRCPATH <<EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
511 > [profiling]
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
512 > type=stat
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
513 > enabled=1
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
514 > EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
515 $ newchg log -r .
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
516 Sample count: * (glob)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
517 $ filteredchg log -r .
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
518 Sample count: * (glob)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
519 (test that we aren't accumulating more and more samples each run)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
520 $ cat > $TESTTMP/debugsleep.py <<EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
521 > import time
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
522 > from mercurial import registrar
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
523 > cmdtable = {}
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
524 > command = registrar.command(cmdtable)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
525 > @command(b'debugsleep', [], b'', norepo=True)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
526 > def debugsleep(ui):
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
527 > start = time.time()
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
528 > x = 0
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
529 > while time.time() < start + 0.5:
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
530 > time.sleep(.1)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
531 > x += 1
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
532 > ui.status(b'%d debugsleep iterations in %.03fs\n' % (x, time.time() - start))
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
533 > EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
534 $ cat >> $HGRCPATH <<EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
535 > [extensions]
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
536 > debugsleep = $TESTTMP/debugsleep.py
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
537 > EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
538 $ newchg debugsleep > run_1
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
539 $ filteredchg debugsleep > run_2
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
540 $ filteredchg debugsleep > run_3
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
541 $ filteredchg debugsleep > run_4
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
542 FIXME: Run 4 should not be >3x Run 1's number of samples.
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
543 $ "$PYTHON" <<EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
544 > r1 = int(open("run_1", "r").read().split()[-1])
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
545 > r4 = int(open("run_4", "r").read().split()[-1])
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
546 > print("Run 1: %d samples\nRun 4: %d samples\nRun 4 > 3 * Run 1: %s" %
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
547 > (r1, r4, r4 > (r1 * 3)))
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
548 > EOF
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
549 Run 1: * samples (glob)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
550 Run 4: * samples (glob)
47024
8fcc0a829f3d chg: pass --no-profile to disable profiling when starting hg serve
Kyle Lippincott <spectral@google.com>
parents: 47023
diff changeset
551 Run 4 > 3 * Run 1: False
47023
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
552 (Disabling with --no-profile on the commandline still works, but isn't permanent)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
553 $ newchg log -r . --no-profile
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
554 $ filteredchg log -r .
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
555 Sample count: * (glob)
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
556 $ filteredchg log -r . --no-profile
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
557 $ filteredchg log -r .
a2bf93ab3014 profiling: add --no-profile to disable profiling enabled via config
Kyle Lippincott <spectral@google.com>
parents: 47022
diff changeset
558 Sample count: * (glob)
50353
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
559
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
560 chg setting CHGHG itself
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
561 ------------------------
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
562
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
563 If CHGHG is not set, chg will set it before spawning the command server.
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
564 $ hg --kill-chg-daemon
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
565 $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
566 > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \
51389
db5d7aee641e tests: tweak chg test to make it fail less often
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50725
diff changeset
567 > | grep -E 'CHGHG|start cmdserver'
50353
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
568 chg: debug: * start cmdserver at * (glob)
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
569 CHGHG=/*/install/bin/hg (glob)
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
570
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
571 Running the same command a second time shouldn't spawn a new command server.
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
572 $ HG=$CHGHG CHGHG= CHGDEBUG= hg debugshell -c \
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
573 > 'ui.write(b"CHGHG=%s\n" % ui.environ.get(b"CHGHG"))' 2>&1 \
51389
db5d7aee641e tests: tweak chg test to make it fail less often
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50725
diff changeset
574 > | grep -E 'CHGHG|start cmdserver'
50353
c2a1f8668606 chg: set CHGHG before connecting to command server
Arun Kulshreshtha <akulshreshtha@janestreet.com>
parents: 50098
diff changeset
575 CHGHG=/*/install/bin/hg (glob)