Debian Codegraph @

tests/test-basic.t

raw
1 Create a repository:
2
3 #if no-extraextensions
4 $ hg config
5 chgserver.idletimeout=60
6 devel.all-warnings=true
7 devel.default-date=0 0
8 extensions.fsmonitor= (fsmonitor !)
9 format.use-dirstate-v2=1 (dirstate-v2 !)
10 largefiles.usercache=$TESTTMP/.cache/largefiles
11 lfs.usercache=$TESTTMP/.cache/lfs
12 ui.slash=True
13 ui.interactive=False
14 ui.detailed-exit-code=True
15 ui.merge=internal:merge
16 ui.mergemarkers=detailed
17 ui.promptecho=True
18 ui.ssh=* (glob)
19 ui.timeout.warn=15
20 web.address=localhost
21 web\.ipv6=(?:True|False) (re)
22 web.server-header=testing stub value
23 #endif
24
25 $ hg init t
26 $ cd t
27
28 Prepare a changeset:
29
30 $ echo a > a
31 $ hg add a
32
33 $ hg status
34 A a
35
36 Writes to stdio succeed and fail appropriately
37
38 #if devfull
39 $ hg status 2>/dev/full
40 A a
41
42 $ hg status >/dev/full
43 abort: No space left on device* (glob)
44 [255]
45 #endif
46
47 #if devfull
48 $ hg status >/dev/full 2>&1
49 [255]
50
51 $ hg status ENOENT 2>/dev/full
52 [255]
53 #endif
54
55 On Python 3, stdio may be None:
56
57 $ hg debuguiprompt --config ui.interactive=true 0<&-
58 abort: Bad file descriptor (no-rhg !)
59 abort: response expected (rhg !)
60 [255]
61 $ hg version -q 0<&-
62 Mercurial Distributed SCM * (glob)
63
64 #if no-rhg
65 $ hg version -q 1>&-
66 abort: Bad file descriptor
67 [255]
68 #else
69 $ hg version -q 1>&-
70 #endif
71 $ hg unknown -q 1>&-
72 hg: unknown command 'unknown'
73 (did you mean debugknown?)
74 [10]
75
76 $ hg version -q 2>&-
77 Mercurial Distributed SCM * (glob)
78 $ hg unknown -q 2>&-
79 [10]
80
81 $ hg commit -m test
82
83 This command is ancient:
84
85 $ hg history
86 changeset: 0:acb14030fe0a
87 tag: tip
88 user: test
89 date: Thu Jan 01 00:00:00 1970 +0000
90 summary: test
91
92
93 Verify that updating to revision 0 via commands.update() works properly
94
95 $ cat <<EOF > update_to_rev0.py
96 > from mercurial import commands, ui as uimod
97 > from mercurial.repo import (
98 > factory as repo_factory,
99 > )
100 > myui = uimod.ui.load()
101 > repo = repo_factory.repository(myui, path=b'.')
102 > commands.update(myui, repo, rev=b"0")
103 > EOF
104 $ hg up null
105 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
106 $ "$PYTHON" ./update_to_rev0.py
107 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 $ hg identify -n
109 0
110
111
112 Poke around at hashes:
113
114 $ hg manifest --debug
115 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
116
117 $ hg cat a
118 a
119
120 Verify should succeed:
121
122 $ hg verify
123 checking changesets
124 checking manifests
125 crosschecking files in changesets and manifests
126 checking files
127 checking dirstate
128 checked 1 changesets with 1 changes to 1 files
129
130 Repository root:
131
132 $ hg root
133 $TESTTMP/t
134 $ hg log -l1 -T '{reporoot}\n'
135 $TESTTMP/t
136 $ hg root -Tjson | sed 's|\\\\|\\|g'
137 [
138 {
139 "hgpath": "$TESTTMP/t/.hg",
140 "reporoot": "$TESTTMP/t",
141 "storepath": "$TESTTMP/t/.hg/store"
142 }
143 ]
144
145 At the end...
146
147 $ cd ..
148
149 Status message redirection:
150
151 $ hg init empty
152
153 status messages are sent to stdout by default:
154
155 $ hg outgoing -R t empty -Tjson 2>/dev/null
156 comparing with empty
157 searching for changes
158 [
159 {
160 "bookmarks": [],
161 "branch": "default",
162 "date": [0, 0],
163 "desc": "test",
164 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
165 "parents": ["0000000000000000000000000000000000000000"],
166 "phase": "draft",
167 "rev": 0,
168 "tags": ["tip"],
169 "user": "test"
170 }
171 ]
172
173 which can be configured to send to stderr, so the output wouldn't be
174 interleaved:
175
176 $ cat <<'EOF' >> "$HGRCPATH"
177 > [ui]
178 > message-output = stderr
179 > EOF
180 $ hg outgoing -R t empty -Tjson 2>/dev/null
181 [
182 {
183 "bookmarks": [],
184 "branch": "default",
185 "date": [0, 0],
186 "desc": "test",
187 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
188 "parents": ["0000000000000000000000000000000000000000"],
189 "phase": "draft",
190 "rev": 0,
191 "tags": ["tip"],
192 "user": "test"
193 }
194 ]
195 $ hg outgoing -R t empty -Tjson >/dev/null
196 comparing with empty
197 searching for changes
198
199 this option should be turned off by HGPLAIN= since it may break scripting use:
200
201 $ HGPLAIN= hg outgoing -R t empty -Tjson 2>/dev/null
202 comparing with empty
203 searching for changes
204 [
205 {
206 "bookmarks": [],
207 "branch": "default",
208 "date": [0, 0],
209 "desc": "test",
210 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
211 "parents": ["0000000000000000000000000000000000000000"],
212 "phase": "draft",
213 "rev": 0,
214 "tags": ["tip"],
215 "user": "test"
216 }
217 ]
218
219 but still overridden by --config:
220
221 $ HGPLAIN= hg outgoing -R t empty -Tjson --config ui.message-output=stderr \
222 > 2>/dev/null
223 [
224 {
225 "bookmarks": [],
226 "branch": "default",
227 "date": [0, 0],
228 "desc": "test",
229 "node": "acb14030fe0a21b60322c440ad2d20cf7685a376",
230 "parents": ["0000000000000000000000000000000000000000"],
231 "phase": "draft",
232 "rev": 0,
233 "tags": ["tip"],
234 "user": "test"
235 }
236 ]
237
238 Invalid ui.message-output option:
239
240 $ hg log -R t --config ui.message-output=bad
241 abort: invalid ui.message-output destination: bad
242 [255]
243
244 Underlying message streams should be updated when ui.fout/ferr are set:
245
246 $ cat <<'EOF' > capui.py
247 > import io
248 > from mercurial import registrar
249 > cmdtable = {}
250 > command = registrar.command(cmdtable)
251 > @command(b'capui', norepo=True)
252 > def capui(ui):
253 > out = ui.fout
254 > ui.fout = io.BytesIO()
255 > ui.status(b'status\n')
256 > ui.ferr = io.BytesIO()
257 > ui.warn(b'warn\n')
258 > out.write(b'stdout: %s' % ui.fout.getvalue())
259 > out.write(b'stderr: %s' % ui.ferr.getvalue())
260 > EOF
261 $ hg --config extensions.capui=capui.py --config ui.message-output=stdio capui
262 stdout: status
263 stderr: warn