Mercurial > hg
annotate tests/test-pager.t @ 32268:24f55686a63d
caches: stop warming the cache after changegroup application
Now that we garantee that branchmap cache is updated at the end of the
transaction we can drop this update. This removes a problematic case with
nested transaction where the new cache could be written on disk before the
transaction is finished (and even roll-backed)
Such premature cache write was visible in the following test:
* tests/test-acl.t
* tests/test-rebase-conflicts.t
In addition, running the cache update later means having more date about the
state of the repository (in particular: phases). So we can generate caches with
more information. This creates harmless changes to the following tests:
* tests/test-hardlinks-whitelisted.t
* tests/test-hardlinks.t
* tests/test-phases.t
* tests/test-tags.t
* tests/test-inherit-mode.t
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 02 May 2017 18:57:52 +0200 |
parents | f06d23af6cdf |
children | 46ba2cdda476 |
rev | line source |
---|---|
28319 | 1 $ cat >> fakepager.py <<EOF |
2 > import sys | |
3 > for line in sys.stdin: | |
4 > sys.stdout.write('paged! %r\n' % line) | |
5 > EOF | |
6 | |
7 Enable ui.formatted because pager won't fire without it, and set up | |
8 pager and tell it to use our fake pager that lets us see when the | |
9 pager was running. | |
10 $ cat >> $HGRCPATH <<EOF | |
11 > [ui] | |
12 > formatted = yes | |
32026
57042e91521a
color: turn on by default (but for windows)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32025
diff
changeset
|
13 > color = no |
28319 | 14 > [pager] |
15 > pager = python $TESTTMP/fakepager.py | |
16 > EOF | |
17 | |
18 $ hg init repo | |
19 $ cd repo | |
20 $ echo a >> a | |
21 $ hg add a | |
22 $ hg ci -m 'add a' | |
23 $ for x in `python $TESTDIR/seq.py 1 10`; do | |
24 > echo a $x >> a | |
25 > hg ci -m "modify a $x" | |
26 > done | |
27 | |
30944
b7e073ae44c4
tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents:
30942
diff
changeset
|
28 By default diff and log are paged, but id is not: |
28319 | 29 |
30 $ hg diff -c 2 --pager=yes | |
31 paged! 'diff -r f4be7687d414 -r bce265549556 a\n' | |
32 paged! '--- a/a\tThu Jan 01 00:00:00 1970 +0000\n' | |
33 paged! '+++ b/a\tThu Jan 01 00:00:00 1970 +0000\n' | |
34 paged! '@@ -1,2 +1,3 @@\n' | |
35 paged! ' a\n' | |
36 paged! ' a 1\n' | |
37 paged! '+a 2\n' | |
38 | |
39 $ hg log --limit 2 | |
40 paged! 'changeset: 10:46106edeeb38\n' | |
41 paged! 'tag: tip\n' | |
42 paged! 'user: test\n' | |
43 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
44 paged! 'summary: modify a 10\n' | |
45 paged! '\n' | |
46 paged! 'changeset: 9:6dd8ea7dd621\n' | |
47 paged! 'user: test\n' | |
48 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
49 paged! 'summary: modify a 9\n' | |
50 paged! '\n' | |
51 | |
30944
b7e073ae44c4
tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents:
30942
diff
changeset
|
52 $ hg id |
b7e073ae44c4
tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents:
30942
diff
changeset
|
53 46106edeeb38 tip |
28319 | 54 |
32098
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
55 We can control the pager from the config |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
56 |
32104
f06d23af6cdf
pager: rename 'pager.enable' to 'ui.paginate'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32103
diff
changeset
|
57 $ hg log --limit 1 --config 'ui.paginate=False' |
32098
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
58 changeset: 10:46106edeeb38 |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
59 tag: tip |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
60 user: test |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
61 date: Thu Jan 01 00:00:00 1970 +0000 |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
62 summary: modify a 10 |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
63 |
32104
f06d23af6cdf
pager: rename 'pager.enable' to 'ui.paginate'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32103
diff
changeset
|
64 $ hg log --limit 1 --config 'ui.paginate=0' |
32098
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
65 changeset: 10:46106edeeb38 |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
66 tag: tip |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
67 user: test |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
68 date: Thu Jan 01 00:00:00 1970 +0000 |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
69 summary: modify a 10 |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
70 |
32104
f06d23af6cdf
pager: rename 'pager.enable' to 'ui.paginate'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32103
diff
changeset
|
71 $ hg log --limit 1 --config 'ui.paginate=1' |
32098
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
72 paged! 'changeset: 10:46106edeeb38\n' |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
73 paged! 'tag: tip\n' |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
74 paged! 'user: test\n' |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
75 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
76 paged! 'summary: modify a 10\n' |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
77 paged! '\n' |
149440d7e1a7
pager: test the 'enable' config option
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32074
diff
changeset
|
78 |
30944
b7e073ae44c4
tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents:
30942
diff
changeset
|
79 We can enable the pager on id: |
28319 | 80 |
31405
d5eb20934c36
tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents:
31079
diff
changeset
|
81 BROKEN: should be paged |
30944
b7e073ae44c4
tests: switch "this command isn't paged" example to id
Augie Fackler <augie@google.com>
parents:
30942
diff
changeset
|
82 $ hg --config pager.attend-id=yes id |
31405
d5eb20934c36
tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents:
31079
diff
changeset
|
83 46106edeeb38 tip |
28319 | 84 |
30996
cc3c9b6f1e09
tests: clean up a bunch of pager testing that is about to be invalidated
Augie Fackler <augie@google.com>
parents:
30944
diff
changeset
|
85 Setting attend-$COMMAND to a false value works, even with pager in |
cc3c9b6f1e09
tests: clean up a bunch of pager testing that is about to be invalidated
Augie Fackler <augie@google.com>
parents:
30944
diff
changeset
|
86 core: |
28319 | 87 $ hg --config pager.attend-diff=no diff -c 2 |
88 diff -r f4be7687d414 -r bce265549556 a | |
89 --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
90 +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
91 @@ -1,2 +1,3 @@ | |
92 a | |
93 a 1 | |
94 +a 2 | |
95 | |
32072
05cdd5678c6b
tests: drop unnecessary pager attend in test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32026
diff
changeset
|
96 Command aliases should have same behavior as main command |
05cdd5678c6b
tests: drop unnecessary pager attend in test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32026
diff
changeset
|
97 |
05cdd5678c6b
tests: drop unnecessary pager attend in test
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32026
diff
changeset
|
98 $ hg history --limit 2 |
28319 | 99 paged! 'changeset: 10:46106edeeb38\n' |
100 paged! 'tag: tip\n' | |
101 paged! 'user: test\n' | |
102 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
103 paged! 'summary: modify a 10\n' | |
104 paged! '\n' | |
105 paged! 'changeset: 9:6dd8ea7dd621\n' | |
106 paged! 'user: test\n' | |
107 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' | |
108 paged! 'summary: modify a 9\n' | |
109 paged! '\n' | |
110 | |
32073
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
111 Abbreviated command alias should also be paged |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
112 |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
113 $ hg hist -l 1 |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
114 paged! 'changeset: 10:46106edeeb38\n' |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
115 paged! 'tag: tip\n' |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
116 paged! 'user: test\n' |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
117 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
118 paged! 'summary: modify a 10\n' |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
119 paged! '\n' |
04629b2da72c
tests: test that abbreviated command alias is also paged
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32072
diff
changeset
|
120 |
32074
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
121 Attend for an abbreviated command does not work |
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
122 |
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
123 $ hg --config pager.attend-ident=true ident |
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
124 46106edeeb38 tip |
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
125 |
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
126 $ hg --config extensions.pager= --config pager.attend-ident=true ident |
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
127 46106edeeb38 tip |
769c831708c7
tests: demonstrate that pager.attend-<abbreviated> doesn't work
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32073
diff
changeset
|
128 |
30847
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
29344
diff
changeset
|
129 Pager should not start if stdout is not a tty. |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
29344
diff
changeset
|
130 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
29344
diff
changeset
|
131 $ hg log -l1 -q --config ui.formatted=False |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
29344
diff
changeset
|
132 10:46106edeeb38 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
29344
diff
changeset
|
133 |
31079
873ebdd6e84d
pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents:
31000
diff
changeset
|
134 Pager should be disabled if pager.pager is empty (otherwise the output would |
873ebdd6e84d
pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents:
31000
diff
changeset
|
135 be silently lost.) |
873ebdd6e84d
pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents:
31000
diff
changeset
|
136 |
873ebdd6e84d
pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents:
31000
diff
changeset
|
137 $ hg log -l1 -q --config pager.pager= |
873ebdd6e84d
pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents:
31000
diff
changeset
|
138 10:46106edeeb38 |
873ebdd6e84d
pager: do not try to run an empty pager command
Yuya Nishihara <yuya@tcha.org>
parents:
31000
diff
changeset
|
139 |
28531
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
140 Pager with color enabled allows colors to come through by default, |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
141 even though stdout is no longer a tty. |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
142 $ cat >> $HGRCPATH <<EOF |
32025
d323d9e0d7b4
pager: stop using the color extension in tests
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31954
diff
changeset
|
143 > [ui] |
32103
9a98023ac8db
color: special case 'always' in 'ui.color'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32102
diff
changeset
|
144 > color = always |
28531
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
145 > [color] |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
146 > mode = ansi |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
147 > EOF |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
148 $ hg log --limit 3 |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
149 paged! '\x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
150 paged! 'tag: tip\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
151 paged! 'user: test\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
152 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
153 paged! 'summary: modify a 10\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
154 paged! '\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
155 paged! '\x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
156 paged! 'user: test\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
157 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
158 paged! 'summary: modify a 9\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
159 paged! '\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
160 paged! '\x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
161 paged! 'user: test\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
162 paged! 'date: Thu Jan 01 00:00:00 1970 +0000\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
163 paged! 'summary: modify a 8\n' |
fe79a5821e5a
test-pager: add a test for pager with color enabled
Augie Fackler <augie@google.com>
parents:
28319
diff
changeset
|
164 paged! '\n' |
29132
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
165 |
31478
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
166 An invalid pager command name is reported sensibly if we don't have to |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
167 use shell=True in the subprocess call: |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
168 $ hg log --limit 3 --config pager.pager=this-command-better-never-exist |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
169 missing pager command 'this-command-better-never-exist', skipping pager |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
170 \x1b[0;33mchangeset: 10:46106edeeb38\x1b[0m (esc) |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
171 tag: tip |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
172 user: test |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
173 date: Thu Jan 01 00:00:00 1970 +0000 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
174 summary: modify a 10 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
175 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
176 \x1b[0;33mchangeset: 9:6dd8ea7dd621\x1b[0m (esc) |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
177 user: test |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
178 date: Thu Jan 01 00:00:00 1970 +0000 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
179 summary: modify a 9 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
180 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
181 \x1b[0;33mchangeset: 8:cff05a6312fe\x1b[0m (esc) |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
182 user: test |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
183 date: Thu Jan 01 00:00:00 1970 +0000 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
184 summary: modify a 8 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
185 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
186 |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
187 A complicated pager command gets worse behavior. Bonus points if you can |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
188 improve this. |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
189 $ hg log --limit 3 \ |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
190 > --config pager.pager='this-command-better-never-exist --seriously' \ |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
191 > 2>/dev/null || true |
9335dc6b2a9c
pager: avoid shell=True on subprocess.Popen for better errors (issue5491)
Augie Fackler <augie@google.com>
parents:
31405
diff
changeset
|
192 |
29132
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
193 Pager works with shell aliases. |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
194 |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
195 $ cat >> $HGRCPATH <<EOF |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
196 > [alias] |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
197 > echoa = !echo a |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
198 > EOF |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
199 |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
200 $ hg echoa |
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
201 a |
31405
d5eb20934c36
tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents:
31079
diff
changeset
|
202 BROKEN: should be paged |
29132
12769703d4ba
dispatch: always load extensions before running shell aliases (issue5230)
Jun Wu <quark@fb.com>
parents:
28531
diff
changeset
|
203 $ hg --config pager.attend-echoa=yes echoa |
31405
d5eb20934c36
tests: duplicate test for pager for old extension and for in-core pager
Martin von Zweigbergk <martinvonz@google.com>
parents:
31079
diff
changeset
|
204 a |
29343
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
205 |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
206 Pager works with hg aliases including environment variables. |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
207 |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
208 $ cat >> $HGRCPATH <<'EOF' |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
209 > [alias] |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
210 > printa = log -T "$A\n" -r 0 |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
211 > EOF |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
212 |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
213 $ A=1 hg --config pager.attend-printa=yes printa |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
214 paged! '1\n' |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
215 $ A=2 hg --config pager.attend-printa=yes printa |
e095b9e753f7
tests: move chg pager test to test-pager.t
Jun Wu <quark@fb.com>
parents:
29132
diff
changeset
|
216 paged! '2\n' |
29344 | 217 |
30942
65a3b4d67a65
pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents:
30847
diff
changeset
|
218 Something that's explicitly attended is still not paginated if the |
65a3b4d67a65
pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents:
30847
diff
changeset
|
219 pager is globally set to off using a flag: |
65a3b4d67a65
pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents:
30847
diff
changeset
|
220 $ A=2 hg --config pager.attend-printa=yes printa --pager=no |
65a3b4d67a65
pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents:
30847
diff
changeset
|
221 2 |
65a3b4d67a65
pager: add a test of --pager=no functionality
Augie Fackler <augie@google.com>
parents:
30847
diff
changeset
|
222 |
29344 | 223 Pager should not override the exit code of other commands |
224 | |
225 $ cat >> $TESTTMP/fortytwo.py <<'EOF' | |
226 > from mercurial import cmdutil, commands | |
227 > cmdtable = {} | |
228 > command = cmdutil.command(cmdtable) | |
229 > @command('fortytwo', [], 'fortytwo', norepo=True) | |
230 > def fortytwo(ui, *opts): | |
231 > ui.write('42\n') | |
232 > return 42 | |
233 > EOF | |
234 | |
235 $ cat >> $HGRCPATH <<'EOF' | |
236 > [extensions] | |
237 > fortytwo = $TESTTMP/fortytwo.py | |
238 > EOF | |
239 | |
240 $ hg fortytwo --pager=on | |
241 paged! '42\n' | |
242 [42] | |
30999
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
243 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
244 A command that asks for paging using ui.pager() directly works: |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
245 $ hg blame a |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
246 paged! ' 0: a\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
247 paged! ' 1: a 1\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
248 paged! ' 2: a 2\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
249 paged! ' 3: a 3\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
250 paged! ' 4: a 4\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
251 paged! ' 5: a 5\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
252 paged! ' 6: a 6\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
253 paged! ' 7: a 7\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
254 paged! ' 8: a 8\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
255 paged! ' 9: a 9\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
256 paged! '10: a 10\n' |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
257 but not with HGPLAIN |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
258 $ HGPLAIN=1 hg blame a |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
259 0: a |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
260 1: a 1 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
261 2: a 2 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
262 3: a 3 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
263 4: a 4 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
264 5: a 5 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
265 6: a 6 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
266 7: a 7 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
267 8: a 8 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
268 9: a 9 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
269 10: a 10 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
270 explicit flags work too: |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
271 $ hg blame --pager=no a |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
272 0: a |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
273 1: a 1 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
274 2: a 2 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
275 3: a 3 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
276 4: a 4 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
277 5: a 5 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
278 6: a 6 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
279 7: a 7 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
280 8: a 8 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
281 9: a 9 |
334cf948c758
annotate: migrate to modern pager API
Augie Fackler <augie@google.com>
parents:
30996
diff
changeset
|
282 10: a 10 |
31000
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
283 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
284 Put annotate in the ignore list for pager: |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
285 $ cat >> $HGRCPATH <<EOF |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
286 > [pager] |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
287 > ignore = annotate |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
288 > EOF |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
289 $ hg blame a |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
290 0: a |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
291 1: a 1 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
292 2: a 2 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
293 3: a 3 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
294 4: a 4 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
295 5: a 5 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
296 6: a 6 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
297 7: a 7 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
298 8: a 8 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
299 9: a 9 |
84ec2d6a2831
tests: prove that ignore works
Augie Fackler <augie@google.com>
parents:
30999
diff
changeset
|
300 10: a 10 |
31954
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
301 |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
302 Environment variables like LESS and LV are set automatically: |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
303 $ cat > $TESTTMP/printlesslv.py <<EOF |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
304 > import os, sys |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
305 > sys.stdin.read() |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
306 > for name in ['LESS', 'LV']: |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
307 > sys.stdout.write(('%s=%s\n') % (name, os.environ.get(name, '-'))) |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
308 > sys.stdout.flush() |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
309 > EOF |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
310 |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
311 $ cat >> $HGRCPATH <<EOF |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
312 > [alias] |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
313 > noop = log -r 0 -T '' |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
314 > [ui] |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
315 > formatted=1 |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
316 > [pager] |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
317 > pager = $PYTHON $TESTTMP/printlesslv.py |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
318 > EOF |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
319 $ unset LESS |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
320 $ unset LV |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
321 $ hg noop --pager=on |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
322 LESS=FRX |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
323 LV=-c |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
324 $ LESS=EFGH hg noop --pager=on |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
325 LESS=EFGH |
e518192d6bac
pager: set some environment variables if they're not set
Jun Wu <quark@fb.com>
parents:
31478
diff
changeset
|
326 LV=-c |