##// END OF EJS Templates
tests: add extra output for fsmonitor at showconfig
FUJIWARA Katsunori -
r33426:29653495 default
parent child Browse files
Show More
@@ -1,36 +1,34 b''
1 # Blacklist for a full testsuite run with fsmonitor enabled.
1 # Blacklist for a full testsuite run with fsmonitor enabled.
2 # Used by fsmonitor-run-tests.
2 # Used by fsmonitor-run-tests.
3 # The following tests all fail because they either use extensions that conflict
3 # The following tests all fail because they either use extensions that conflict
4 # with fsmonitor, use subrepositories, or don't anticipate the extra file in
4 # with fsmonitor, use subrepositories, or don't anticipate the extra file in
5 # the .hg directory that fsmonitor adds.
5 # the .hg directory that fsmonitor adds.
6 test-basic.t
7 test-commandserver.t
8 test-debugextensions.t
6 test-debugextensions.t
9 test-eol-add.t
7 test-eol-add.t
10 test-eol-clone.t
8 test-eol-clone.t
11 test-eol-hook.t
9 test-eol-hook.t
12 test-eol-patch.t
10 test-eol-patch.t
13 test-eol-tag.t
11 test-eol-tag.t
14 test-eol-update.t
12 test-eol-update.t
15 test-eol.t
13 test-eol.t
16 test-eolfilename.t
14 test-eolfilename.t
17 test-extension.t
15 test-extension.t
18 test-fncache.t
16 test-fncache.t
19 test-hardlinks.t
17 test-hardlinks.t
20 test-help.t
18 test-help.t
21 test-inherit-mode.t
19 test-inherit-mode.t
22 test-issue3084.t
20 test-issue3084.t
23 test-largefiles-cache.t
21 test-largefiles-cache.t
24 test-largefiles-misc.t
22 test-largefiles-misc.t
25 test-largefiles-small-disk.t
23 test-largefiles-small-disk.t
26 test-largefiles-update.t
24 test-largefiles-update.t
27 test-largefiles-wireproto.t
25 test-largefiles-wireproto.t
28 test-largefiles.t
26 test-largefiles.t
29 test-lfconvert.t
27 test-lfconvert.t
30 test-nested-repo.t
28 test-nested-repo.t
31 test-permissions.t
29 test-permissions.t
32 test-push-warn.t
30 test-push-warn.t
33 test-subrepo-deep-nested-change.t
31 test-subrepo-deep-nested-change.t
34 test-subrepo-recursion.t
32 test-subrepo-recursion.t
35 test-subrepo.t
33 test-subrepo.t
36 test-tags.t
34 test-tags.t
@@ -1,88 +1,89 b''
1 Create a repository:
1 Create a repository:
2
2
3 $ hg config
3 $ hg config
4 devel.all-warnings=true
4 devel.all-warnings=true
5 devel.default-date=0 0
5 devel.default-date=0 0
6 extensions.fsmonitor= (fsmonitor !)
6 largefiles.usercache=$TESTTMP/.cache/largefiles (glob)
7 largefiles.usercache=$TESTTMP/.cache/largefiles (glob)
7 ui.slash=True
8 ui.slash=True
8 ui.interactive=False
9 ui.interactive=False
9 ui.mergemarkers=detailed
10 ui.mergemarkers=detailed
10 ui.promptecho=True
11 ui.promptecho=True
11 web.address=localhost
12 web.address=localhost
12 web\.ipv6=(?:True|False) (re)
13 web\.ipv6=(?:True|False) (re)
13 $ hg init t
14 $ hg init t
14 $ cd t
15 $ cd t
15
16
16 Prepare a changeset:
17 Prepare a changeset:
17
18
18 $ echo a > a
19 $ echo a > a
19 $ hg add a
20 $ hg add a
20
21
21 $ hg status
22 $ hg status
22 A a
23 A a
23
24
24 Writes to stdio succeed and fail appropriately
25 Writes to stdio succeed and fail appropriately
25
26
26 #if devfull
27 #if devfull
27 $ hg status 2>/dev/full
28 $ hg status 2>/dev/full
28 A a
29 A a
29
30
30 $ hg status >/dev/full
31 $ hg status >/dev/full
31 abort: No space left on device
32 abort: No space left on device
32 [255]
33 [255]
33
34
34 $ hg status >/dev/full 2>&1
35 $ hg status >/dev/full 2>&1
35 [1]
36 [1]
36
37
37 $ hg status ENOENT 2>/dev/full
38 $ hg status ENOENT 2>/dev/full
38 [1]
39 [1]
39 #endif
40 #endif
40
41
41 $ hg commit -m test
42 $ hg commit -m test
42
43
43 This command is ancient:
44 This command is ancient:
44
45
45 $ hg history
46 $ hg history
46 changeset: 0:acb14030fe0a
47 changeset: 0:acb14030fe0a
47 tag: tip
48 tag: tip
48 user: test
49 user: test
49 date: Thu Jan 01 00:00:00 1970 +0000
50 date: Thu Jan 01 00:00:00 1970 +0000
50 summary: test
51 summary: test
51
52
52
53
53 Verify that updating to revision 0 via commands.update() works properly
54 Verify that updating to revision 0 via commands.update() works properly
54
55
55 $ cat <<EOF > update_to_rev0.py
56 $ cat <<EOF > update_to_rev0.py
56 > from mercurial import ui, hg, commands
57 > from mercurial import ui, hg, commands
57 > myui = ui.ui.load()
58 > myui = ui.ui.load()
58 > repo = hg.repository(myui, path='.')
59 > repo = hg.repository(myui, path='.')
59 > commands.update(myui, repo, rev=0)
60 > commands.update(myui, repo, rev=0)
60 > EOF
61 > EOF
61 $ hg up null
62 $ hg up null
62 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
63 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
63 $ $PYTHON ./update_to_rev0.py
64 $ $PYTHON ./update_to_rev0.py
64 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 $ hg identify -n
66 $ hg identify -n
66 0
67 0
67
68
68
69
69 Poke around at hashes:
70 Poke around at hashes:
70
71
71 $ hg manifest --debug
72 $ hg manifest --debug
72 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
73 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644 a
73
74
74 $ hg cat a
75 $ hg cat a
75 a
76 a
76
77
77 Verify should succeed:
78 Verify should succeed:
78
79
79 $ hg verify
80 $ hg verify
80 checking changesets
81 checking changesets
81 checking manifests
82 checking manifests
82 crosschecking files in changesets and manifests
83 crosschecking files in changesets and manifests
83 checking files
84 checking files
84 1 files, 1 changesets, 1 total revisions
85 1 files, 1 changesets, 1 total revisions
85
86
86 At the end...
87 At the end...
87
88
88 $ cd ..
89 $ cd ..
@@ -1,906 +1,907 b''
1 #if windows
1 #if windows
2 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
2 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
3 #else
3 #else
4 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
4 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
5 #endif
5 #endif
6 $ export PYTHONPATH
6 $ export PYTHONPATH
7
7
8 typical client does not want echo-back messages, so test without it:
8 typical client does not want echo-back messages, so test without it:
9
9
10 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
10 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
11 $ mv $HGRCPATH.new $HGRCPATH
11 $ mv $HGRCPATH.new $HGRCPATH
12
12
13 $ hg init repo
13 $ hg init repo
14 $ cd repo
14 $ cd repo
15
15
16 >>> from __future__ import print_function
16 >>> from __future__ import print_function
17 >>> from hgclient import readchannel, runcommand, check
17 >>> from hgclient import readchannel, runcommand, check
18 >>> @check
18 >>> @check
19 ... def hellomessage(server):
19 ... def hellomessage(server):
20 ... ch, data = readchannel(server)
20 ... ch, data = readchannel(server)
21 ... print('%c, %r' % (ch, data))
21 ... print('%c, %r' % (ch, data))
22 ... # run an arbitrary command to make sure the next thing the server
22 ... # run an arbitrary command to make sure the next thing the server
23 ... # sends isn't part of the hello message
23 ... # sends isn't part of the hello message
24 ... runcommand(server, ['id'])
24 ... runcommand(server, ['id'])
25 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
25 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
26 *** runcommand id
26 *** runcommand id
27 000000000000 tip
27 000000000000 tip
28
28
29 >>> from hgclient import check
29 >>> from hgclient import check
30 >>> @check
30 >>> @check
31 ... def unknowncommand(server):
31 ... def unknowncommand(server):
32 ... server.stdin.write('unknowncommand\n')
32 ... server.stdin.write('unknowncommand\n')
33 abort: unknown command unknowncommand
33 abort: unknown command unknowncommand
34
34
35 >>> from hgclient import readchannel, runcommand, check
35 >>> from hgclient import readchannel, runcommand, check
36 >>> @check
36 >>> @check
37 ... def checkruncommand(server):
37 ... def checkruncommand(server):
38 ... # hello block
38 ... # hello block
39 ... readchannel(server)
39 ... readchannel(server)
40 ...
40 ...
41 ... # no args
41 ... # no args
42 ... runcommand(server, [])
42 ... runcommand(server, [])
43 ...
43 ...
44 ... # global options
44 ... # global options
45 ... runcommand(server, ['id', '--quiet'])
45 ... runcommand(server, ['id', '--quiet'])
46 ...
46 ...
47 ... # make sure global options don't stick through requests
47 ... # make sure global options don't stick through requests
48 ... runcommand(server, ['id'])
48 ... runcommand(server, ['id'])
49 ...
49 ...
50 ... # --config
50 ... # --config
51 ... runcommand(server, ['id', '--config', 'ui.quiet=True'])
51 ... runcommand(server, ['id', '--config', 'ui.quiet=True'])
52 ...
52 ...
53 ... # make sure --config doesn't stick
53 ... # make sure --config doesn't stick
54 ... runcommand(server, ['id'])
54 ... runcommand(server, ['id'])
55 ...
55 ...
56 ... # negative return code should be masked
56 ... # negative return code should be masked
57 ... runcommand(server, ['id', '-runknown'])
57 ... runcommand(server, ['id', '-runknown'])
58 *** runcommand
58 *** runcommand
59 Mercurial Distributed SCM
59 Mercurial Distributed SCM
60
60
61 basic commands:
61 basic commands:
62
62
63 add add the specified files on the next commit
63 add add the specified files on the next commit
64 annotate show changeset information by line for each file
64 annotate show changeset information by line for each file
65 clone make a copy of an existing repository
65 clone make a copy of an existing repository
66 commit commit the specified files or all outstanding changes
66 commit commit the specified files or all outstanding changes
67 diff diff repository (or selected files)
67 diff diff repository (or selected files)
68 export dump the header and diffs for one or more changesets
68 export dump the header and diffs for one or more changesets
69 forget forget the specified files on the next commit
69 forget forget the specified files on the next commit
70 init create a new repository in the given directory
70 init create a new repository in the given directory
71 log show revision history of entire repository or files
71 log show revision history of entire repository or files
72 merge merge another revision into working directory
72 merge merge another revision into working directory
73 pull pull changes from the specified source
73 pull pull changes from the specified source
74 push push changes to the specified destination
74 push push changes to the specified destination
75 remove remove the specified files on the next commit
75 remove remove the specified files on the next commit
76 serve start stand-alone webserver
76 serve start stand-alone webserver
77 status show changed files in the working directory
77 status show changed files in the working directory
78 summary summarize working directory state
78 summary summarize working directory state
79 update update working directory (or switch revisions)
79 update update working directory (or switch revisions)
80
80
81 (use 'hg help' for the full list of commands or 'hg -v' for details)
81 (use 'hg help' for the full list of commands or 'hg -v' for details)
82 *** runcommand id --quiet
82 *** runcommand id --quiet
83 000000000000
83 000000000000
84 *** runcommand id
84 *** runcommand id
85 000000000000 tip
85 000000000000 tip
86 *** runcommand id --config ui.quiet=True
86 *** runcommand id --config ui.quiet=True
87 000000000000
87 000000000000
88 *** runcommand id
88 *** runcommand id
89 000000000000 tip
89 000000000000 tip
90 *** runcommand id -runknown
90 *** runcommand id -runknown
91 abort: unknown revision 'unknown'!
91 abort: unknown revision 'unknown'!
92 [255]
92 [255]
93
93
94 >>> from hgclient import readchannel, check
94 >>> from hgclient import readchannel, check
95 >>> @check
95 >>> @check
96 ... def inputeof(server):
96 ... def inputeof(server):
97 ... readchannel(server)
97 ... readchannel(server)
98 ... server.stdin.write('runcommand\n')
98 ... server.stdin.write('runcommand\n')
99 ... # close stdin while server is waiting for input
99 ... # close stdin while server is waiting for input
100 ... server.stdin.close()
100 ... server.stdin.close()
101 ...
101 ...
102 ... # server exits with 1 if the pipe closed while reading the command
102 ... # server exits with 1 if the pipe closed while reading the command
103 ... print('server exit code =', server.wait())
103 ... print('server exit code =', server.wait())
104 server exit code = 1
104 server exit code = 1
105
105
106 >>> from hgclient import readchannel, runcommand, check, stringio
106 >>> from hgclient import readchannel, runcommand, check, stringio
107 >>> @check
107 >>> @check
108 ... def serverinput(server):
108 ... def serverinput(server):
109 ... readchannel(server)
109 ... readchannel(server)
110 ...
110 ...
111 ... patch = """
111 ... patch = """
112 ... # HG changeset patch
112 ... # HG changeset patch
113 ... # User test
113 ... # User test
114 ... # Date 0 0
114 ... # Date 0 0
115 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
115 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
116 ... # Parent 0000000000000000000000000000000000000000
116 ... # Parent 0000000000000000000000000000000000000000
117 ... 1
117 ... 1
118 ...
118 ...
119 ... diff -r 000000000000 -r c103a3dec114 a
119 ... diff -r 000000000000 -r c103a3dec114 a
120 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
120 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
121 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
121 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
122 ... @@ -0,0 +1,1 @@
122 ... @@ -0,0 +1,1 @@
123 ... +1
123 ... +1
124 ... """
124 ... """
125 ...
125 ...
126 ... runcommand(server, ['import', '-'], input=stringio(patch))
126 ... runcommand(server, ['import', '-'], input=stringio(patch))
127 ... runcommand(server, ['log'])
127 ... runcommand(server, ['log'])
128 *** runcommand import -
128 *** runcommand import -
129 applying patch from stdin
129 applying patch from stdin
130 *** runcommand log
130 *** runcommand log
131 changeset: 0:eff892de26ec
131 changeset: 0:eff892de26ec
132 tag: tip
132 tag: tip
133 user: test
133 user: test
134 date: Thu Jan 01 00:00:00 1970 +0000
134 date: Thu Jan 01 00:00:00 1970 +0000
135 summary: 1
135 summary: 1
136
136
137
137
138 check that "histedit --commands=-" can read rules from the input channel:
138 check that "histedit --commands=-" can read rules from the input channel:
139
139
140 >>> import cStringIO
140 >>> import cStringIO
141 >>> from hgclient import readchannel, runcommand, check
141 >>> from hgclient import readchannel, runcommand, check
142 >>> @check
142 >>> @check
143 ... def serverinput(server):
143 ... def serverinput(server):
144 ... readchannel(server)
144 ... readchannel(server)
145 ... rules = 'pick eff892de26ec\n'
145 ... rules = 'pick eff892de26ec\n'
146 ... runcommand(server, ['histedit', '0', '--commands=-',
146 ... runcommand(server, ['histedit', '0', '--commands=-',
147 ... '--config', 'extensions.histedit='],
147 ... '--config', 'extensions.histedit='],
148 ... input=cStringIO.StringIO(rules))
148 ... input=cStringIO.StringIO(rules))
149 *** runcommand histedit 0 --commands=- --config extensions.histedit=
149 *** runcommand histedit 0 --commands=- --config extensions.histedit=
150
150
151 check that --cwd doesn't persist between requests:
151 check that --cwd doesn't persist between requests:
152
152
153 $ mkdir foo
153 $ mkdir foo
154 $ touch foo/bar
154 $ touch foo/bar
155 >>> from hgclient import readchannel, runcommand, check
155 >>> from hgclient import readchannel, runcommand, check
156 >>> @check
156 >>> @check
157 ... def cwd(server):
157 ... def cwd(server):
158 ... readchannel(server)
158 ... readchannel(server)
159 ... runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
159 ... runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
160 ... runcommand(server, ['st', 'foo/bar'])
160 ... runcommand(server, ['st', 'foo/bar'])
161 *** runcommand --cwd foo st bar
161 *** runcommand --cwd foo st bar
162 ? bar
162 ? bar
163 *** runcommand st foo/bar
163 *** runcommand st foo/bar
164 ? foo/bar
164 ? foo/bar
165
165
166 $ rm foo/bar
166 $ rm foo/bar
167
167
168
168
169 check that local configs for the cached repo aren't inherited when -R is used:
169 check that local configs for the cached repo aren't inherited when -R is used:
170
170
171 $ cat <<EOF >> .hg/hgrc
171 $ cat <<EOF >> .hg/hgrc
172 > [ui]
172 > [ui]
173 > foo = bar
173 > foo = bar
174 > EOF
174 > EOF
175
175
176 >>> from hgclient import readchannel, sep, runcommand, check
176 >>> from hgclient import readchannel, sep, runcommand, check
177 >>> @check
177 >>> @check
178 ... def localhgrc(server):
178 ... def localhgrc(server):
179 ... readchannel(server)
179 ... readchannel(server)
180 ...
180 ...
181 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
181 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
182 ... # show it
182 ... # show it
183 ... runcommand(server, ['showconfig'], outfilter=sep)
183 ... runcommand(server, ['showconfig'], outfilter=sep)
184 ...
184 ...
185 ... # but not for this repo
185 ... # but not for this repo
186 ... runcommand(server, ['init', 'foo'])
186 ... runcommand(server, ['init', 'foo'])
187 ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
187 ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
188 *** runcommand showconfig
188 *** runcommand showconfig
189 bundle.mainreporoot=$TESTTMP/repo
189 bundle.mainreporoot=$TESTTMP/repo
190 devel.all-warnings=true
190 devel.all-warnings=true
191 devel.default-date=0 0
191 devel.default-date=0 0
192 extensions.fsmonitor= (fsmonitor !)
192 largefiles.usercache=$TESTTMP/.cache/largefiles
193 largefiles.usercache=$TESTTMP/.cache/largefiles
193 ui.slash=True
194 ui.slash=True
194 ui.interactive=False
195 ui.interactive=False
195 ui.mergemarkers=detailed
196 ui.mergemarkers=detailed
196 ui.usehttp2=true (?)
197 ui.usehttp2=true (?)
197 ui.foo=bar
198 ui.foo=bar
198 ui.nontty=true
199 ui.nontty=true
199 web.address=localhost
200 web.address=localhost
200 web\.ipv6=(?:True|False) (re)
201 web\.ipv6=(?:True|False) (re)
201 *** runcommand init foo
202 *** runcommand init foo
202 *** runcommand -R foo showconfig ui defaults
203 *** runcommand -R foo showconfig ui defaults
203 ui.slash=True
204 ui.slash=True
204 ui.interactive=False
205 ui.interactive=False
205 ui.mergemarkers=detailed
206 ui.mergemarkers=detailed
206 ui.usehttp2=true (?)
207 ui.usehttp2=true (?)
207 ui.nontty=true
208 ui.nontty=true
208
209
209 $ rm -R foo
210 $ rm -R foo
210
211
211 #if windows
212 #if windows
212 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
213 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
213 #else
214 #else
214 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
215 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
215 #endif
216 #endif
216
217
217 $ cat <<EOF > hook.py
218 $ cat <<EOF > hook.py
218 > from __future__ import print_function
219 > from __future__ import print_function
219 > import sys
220 > import sys
220 > def hook(**args):
221 > def hook(**args):
221 > print('hook talking')
222 > print('hook talking')
222 > print('now try to read something: %r' % sys.stdin.read())
223 > print('now try to read something: %r' % sys.stdin.read())
223 > EOF
224 > EOF
224
225
225 >>> from hgclient import readchannel, runcommand, check, stringio
226 >>> from hgclient import readchannel, runcommand, check, stringio
226 >>> @check
227 >>> @check
227 ... def hookoutput(server):
228 ... def hookoutput(server):
228 ... readchannel(server)
229 ... readchannel(server)
229 ... runcommand(server, ['--config',
230 ... runcommand(server, ['--config',
230 ... 'hooks.pre-identify=python:hook.hook',
231 ... 'hooks.pre-identify=python:hook.hook',
231 ... 'id'],
232 ... 'id'],
232 ... input=stringio('some input'))
233 ... input=stringio('some input'))
233 *** runcommand --config hooks.pre-identify=python:hook.hook id
234 *** runcommand --config hooks.pre-identify=python:hook.hook id
234 eff892de26ec tip
235 eff892de26ec tip
235
236
236 $ rm hook.py*
237 $ rm hook.py*
237
238
238 $ echo a >> a
239 $ echo a >> a
239 >>> import os
240 >>> import os
240 >>> from hgclient import readchannel, runcommand, check
241 >>> from hgclient import readchannel, runcommand, check
241 >>> @check
242 >>> @check
242 ... def outsidechanges(server):
243 ... def outsidechanges(server):
243 ... readchannel(server)
244 ... readchannel(server)
244 ... runcommand(server, ['status'])
245 ... runcommand(server, ['status'])
245 ... os.system('hg ci -Am2')
246 ... os.system('hg ci -Am2')
246 ... runcommand(server, ['tip'])
247 ... runcommand(server, ['tip'])
247 ... runcommand(server, ['status'])
248 ... runcommand(server, ['status'])
248 *** runcommand status
249 *** runcommand status
249 M a
250 M a
250 *** runcommand tip
251 *** runcommand tip
251 changeset: 1:d3a0a68be6de
252 changeset: 1:d3a0a68be6de
252 tag: tip
253 tag: tip
253 user: test
254 user: test
254 date: Thu Jan 01 00:00:00 1970 +0000
255 date: Thu Jan 01 00:00:00 1970 +0000
255 summary: 2
256 summary: 2
256
257
257 *** runcommand status
258 *** runcommand status
258
259
259 >>> import os
260 >>> import os
260 >>> from hgclient import readchannel, runcommand, check
261 >>> from hgclient import readchannel, runcommand, check
261 >>> @check
262 >>> @check
262 ... def bookmarks(server):
263 ... def bookmarks(server):
263 ... readchannel(server)
264 ... readchannel(server)
264 ... runcommand(server, ['bookmarks'])
265 ... runcommand(server, ['bookmarks'])
265 ...
266 ...
266 ... # changes .hg/bookmarks
267 ... # changes .hg/bookmarks
267 ... os.system('hg bookmark -i bm1')
268 ... os.system('hg bookmark -i bm1')
268 ... os.system('hg bookmark -i bm2')
269 ... os.system('hg bookmark -i bm2')
269 ... runcommand(server, ['bookmarks'])
270 ... runcommand(server, ['bookmarks'])
270 ...
271 ...
271 ... # changes .hg/bookmarks.current
272 ... # changes .hg/bookmarks.current
272 ... os.system('hg upd bm1 -q')
273 ... os.system('hg upd bm1 -q')
273 ... runcommand(server, ['bookmarks'])
274 ... runcommand(server, ['bookmarks'])
274 ...
275 ...
275 ... runcommand(server, ['bookmarks', 'bm3'])
276 ... runcommand(server, ['bookmarks', 'bm3'])
276 ... f = open('a', 'ab')
277 ... f = open('a', 'ab')
277 ... f.write('a\n')
278 ... f.write('a\n')
278 ... f.close()
279 ... f.close()
279 ... runcommand(server, ['commit', '-Amm'])
280 ... runcommand(server, ['commit', '-Amm'])
280 ... runcommand(server, ['bookmarks'])
281 ... runcommand(server, ['bookmarks'])
281 *** runcommand bookmarks
282 *** runcommand bookmarks
282 no bookmarks set
283 no bookmarks set
283 *** runcommand bookmarks
284 *** runcommand bookmarks
284 bm1 1:d3a0a68be6de
285 bm1 1:d3a0a68be6de
285 bm2 1:d3a0a68be6de
286 bm2 1:d3a0a68be6de
286 *** runcommand bookmarks
287 *** runcommand bookmarks
287 * bm1 1:d3a0a68be6de
288 * bm1 1:d3a0a68be6de
288 bm2 1:d3a0a68be6de
289 bm2 1:d3a0a68be6de
289 *** runcommand bookmarks bm3
290 *** runcommand bookmarks bm3
290 *** runcommand commit -Amm
291 *** runcommand commit -Amm
291 *** runcommand bookmarks
292 *** runcommand bookmarks
292 bm1 1:d3a0a68be6de
293 bm1 1:d3a0a68be6de
293 bm2 1:d3a0a68be6de
294 bm2 1:d3a0a68be6de
294 * bm3 2:aef17e88f5f0
295 * bm3 2:aef17e88f5f0
295
296
296 >>> import os
297 >>> import os
297 >>> from hgclient import readchannel, runcommand, check
298 >>> from hgclient import readchannel, runcommand, check
298 >>> @check
299 >>> @check
299 ... def tagscache(server):
300 ... def tagscache(server):
300 ... readchannel(server)
301 ... readchannel(server)
301 ... runcommand(server, ['id', '-t', '-r', '0'])
302 ... runcommand(server, ['id', '-t', '-r', '0'])
302 ... os.system('hg tag -r 0 foo')
303 ... os.system('hg tag -r 0 foo')
303 ... runcommand(server, ['id', '-t', '-r', '0'])
304 ... runcommand(server, ['id', '-t', '-r', '0'])
304 *** runcommand id -t -r 0
305 *** runcommand id -t -r 0
305
306
306 *** runcommand id -t -r 0
307 *** runcommand id -t -r 0
307 foo
308 foo
308
309
309 >>> import os
310 >>> import os
310 >>> from hgclient import readchannel, runcommand, check
311 >>> from hgclient import readchannel, runcommand, check
311 >>> @check
312 >>> @check
312 ... def setphase(server):
313 ... def setphase(server):
313 ... readchannel(server)
314 ... readchannel(server)
314 ... runcommand(server, ['phase', '-r', '.'])
315 ... runcommand(server, ['phase', '-r', '.'])
315 ... os.system('hg phase -r . -p')
316 ... os.system('hg phase -r . -p')
316 ... runcommand(server, ['phase', '-r', '.'])
317 ... runcommand(server, ['phase', '-r', '.'])
317 *** runcommand phase -r .
318 *** runcommand phase -r .
318 3: draft
319 3: draft
319 *** runcommand phase -r .
320 *** runcommand phase -r .
320 3: public
321 3: public
321
322
322 $ echo a >> a
323 $ echo a >> a
323 >>> from hgclient import readchannel, runcommand, check
324 >>> from hgclient import readchannel, runcommand, check
324 >>> @check
325 >>> @check
325 ... def rollback(server):
326 ... def rollback(server):
326 ... readchannel(server)
327 ... readchannel(server)
327 ... runcommand(server, ['phase', '-r', '.', '-p'])
328 ... runcommand(server, ['phase', '-r', '.', '-p'])
328 ... runcommand(server, ['commit', '-Am.'])
329 ... runcommand(server, ['commit', '-Am.'])
329 ... runcommand(server, ['rollback'])
330 ... runcommand(server, ['rollback'])
330 ... runcommand(server, ['phase', '-r', '.'])
331 ... runcommand(server, ['phase', '-r', '.'])
331 *** runcommand phase -r . -p
332 *** runcommand phase -r . -p
332 no phases changed
333 no phases changed
333 *** runcommand commit -Am.
334 *** runcommand commit -Am.
334 *** runcommand rollback
335 *** runcommand rollback
335 repository tip rolled back to revision 3 (undo commit)
336 repository tip rolled back to revision 3 (undo commit)
336 working directory now based on revision 3
337 working directory now based on revision 3
337 *** runcommand phase -r .
338 *** runcommand phase -r .
338 3: public
339 3: public
339
340
340 >>> import os
341 >>> import os
341 >>> from hgclient import readchannel, runcommand, check
342 >>> from hgclient import readchannel, runcommand, check
342 >>> @check
343 >>> @check
343 ... def branch(server):
344 ... def branch(server):
344 ... readchannel(server)
345 ... readchannel(server)
345 ... runcommand(server, ['branch'])
346 ... runcommand(server, ['branch'])
346 ... os.system('hg branch foo')
347 ... os.system('hg branch foo')
347 ... runcommand(server, ['branch'])
348 ... runcommand(server, ['branch'])
348 ... os.system('hg branch default')
349 ... os.system('hg branch default')
349 *** runcommand branch
350 *** runcommand branch
350 default
351 default
351 marked working directory as branch foo
352 marked working directory as branch foo
352 (branches are permanent and global, did you want a bookmark?)
353 (branches are permanent and global, did you want a bookmark?)
353 *** runcommand branch
354 *** runcommand branch
354 foo
355 foo
355 marked working directory as branch default
356 marked working directory as branch default
356 (branches are permanent and global, did you want a bookmark?)
357 (branches are permanent and global, did you want a bookmark?)
357
358
358 $ touch .hgignore
359 $ touch .hgignore
359 >>> import os
360 >>> import os
360 >>> from hgclient import readchannel, runcommand, check
361 >>> from hgclient import readchannel, runcommand, check
361 >>> @check
362 >>> @check
362 ... def hgignore(server):
363 ... def hgignore(server):
363 ... readchannel(server)
364 ... readchannel(server)
364 ... runcommand(server, ['commit', '-Am.'])
365 ... runcommand(server, ['commit', '-Am.'])
365 ... f = open('ignored-file', 'ab')
366 ... f = open('ignored-file', 'ab')
366 ... f.write('')
367 ... f.write('')
367 ... f.close()
368 ... f.close()
368 ... f = open('.hgignore', 'ab')
369 ... f = open('.hgignore', 'ab')
369 ... f.write('ignored-file')
370 ... f.write('ignored-file')
370 ... f.close()
371 ... f.close()
371 ... runcommand(server, ['status', '-i', '-u'])
372 ... runcommand(server, ['status', '-i', '-u'])
372 *** runcommand commit -Am.
373 *** runcommand commit -Am.
373 adding .hgignore
374 adding .hgignore
374 *** runcommand status -i -u
375 *** runcommand status -i -u
375 I ignored-file
376 I ignored-file
376
377
377 cache of non-public revisions should be invalidated on repository change
378 cache of non-public revisions should be invalidated on repository change
378 (issue4855):
379 (issue4855):
379
380
380 >>> import os
381 >>> import os
381 >>> from hgclient import readchannel, runcommand, check
382 >>> from hgclient import readchannel, runcommand, check
382 >>> @check
383 >>> @check
383 ... def phasesetscacheaftercommit(server):
384 ... def phasesetscacheaftercommit(server):
384 ... readchannel(server)
385 ... readchannel(server)
385 ... # load _phasecache._phaserevs and _phasesets
386 ... # load _phasecache._phaserevs and _phasesets
386 ... runcommand(server, ['log', '-qr', 'draft()'])
387 ... runcommand(server, ['log', '-qr', 'draft()'])
387 ... # create draft commits by another process
388 ... # create draft commits by another process
388 ... for i in xrange(5, 7):
389 ... for i in xrange(5, 7):
389 ... f = open('a', 'ab')
390 ... f = open('a', 'ab')
390 ... f.seek(0, os.SEEK_END)
391 ... f.seek(0, os.SEEK_END)
391 ... f.write('a\n')
392 ... f.write('a\n')
392 ... f.close()
393 ... f.close()
393 ... os.system('hg commit -Aqm%d' % i)
394 ... os.system('hg commit -Aqm%d' % i)
394 ... # new commits should be listed as draft revisions
395 ... # new commits should be listed as draft revisions
395 ... runcommand(server, ['log', '-qr', 'draft()'])
396 ... runcommand(server, ['log', '-qr', 'draft()'])
396 *** runcommand log -qr draft()
397 *** runcommand log -qr draft()
397 4:7966c8e3734d
398 4:7966c8e3734d
398 *** runcommand log -qr draft()
399 *** runcommand log -qr draft()
399 4:7966c8e3734d
400 4:7966c8e3734d
400 5:41f6602d1c4f
401 5:41f6602d1c4f
401 6:10501e202c35
402 6:10501e202c35
402
403
403 >>> import os
404 >>> import os
404 >>> from hgclient import readchannel, runcommand, check
405 >>> from hgclient import readchannel, runcommand, check
405 >>> @check
406 >>> @check
406 ... def phasesetscacheafterstrip(server):
407 ... def phasesetscacheafterstrip(server):
407 ... readchannel(server)
408 ... readchannel(server)
408 ... # load _phasecache._phaserevs and _phasesets
409 ... # load _phasecache._phaserevs and _phasesets
409 ... runcommand(server, ['log', '-qr', 'draft()'])
410 ... runcommand(server, ['log', '-qr', 'draft()'])
410 ... # strip cached revisions by another process
411 ... # strip cached revisions by another process
411 ... os.system('hg --config extensions.strip= strip -q 5')
412 ... os.system('hg --config extensions.strip= strip -q 5')
412 ... # shouldn't abort by "unknown revision '6'"
413 ... # shouldn't abort by "unknown revision '6'"
413 ... runcommand(server, ['log', '-qr', 'draft()'])
414 ... runcommand(server, ['log', '-qr', 'draft()'])
414 *** runcommand log -qr draft()
415 *** runcommand log -qr draft()
415 4:7966c8e3734d
416 4:7966c8e3734d
416 5:41f6602d1c4f
417 5:41f6602d1c4f
417 6:10501e202c35
418 6:10501e202c35
418 *** runcommand log -qr draft()
419 *** runcommand log -qr draft()
419 4:7966c8e3734d
420 4:7966c8e3734d
420
421
421 cache of phase roots should be invalidated on strip (issue3827):
422 cache of phase roots should be invalidated on strip (issue3827):
422
423
423 >>> import os
424 >>> import os
424 >>> from hgclient import readchannel, sep, runcommand, check
425 >>> from hgclient import readchannel, sep, runcommand, check
425 >>> @check
426 >>> @check
426 ... def phasecacheafterstrip(server):
427 ... def phasecacheafterstrip(server):
427 ... readchannel(server)
428 ... readchannel(server)
428 ...
429 ...
429 ... # create new head, 5:731265503d86
430 ... # create new head, 5:731265503d86
430 ... runcommand(server, ['update', '-C', '0'])
431 ... runcommand(server, ['update', '-C', '0'])
431 ... f = open('a', 'ab')
432 ... f = open('a', 'ab')
432 ... f.write('a\n')
433 ... f.write('a\n')
433 ... f.close()
434 ... f.close()
434 ... runcommand(server, ['commit', '-Am.', 'a'])
435 ... runcommand(server, ['commit', '-Am.', 'a'])
435 ... runcommand(server, ['log', '-Gq'])
436 ... runcommand(server, ['log', '-Gq'])
436 ...
437 ...
437 ... # make it public; draft marker moves to 4:7966c8e3734d
438 ... # make it public; draft marker moves to 4:7966c8e3734d
438 ... runcommand(server, ['phase', '-p', '.'])
439 ... runcommand(server, ['phase', '-p', '.'])
439 ... # load _phasecache.phaseroots
440 ... # load _phasecache.phaseroots
440 ... runcommand(server, ['phase', '.'], outfilter=sep)
441 ... runcommand(server, ['phase', '.'], outfilter=sep)
441 ...
442 ...
442 ... # strip 1::4 outside server
443 ... # strip 1::4 outside server
443 ... os.system('hg -q --config extensions.mq= strip 1')
444 ... os.system('hg -q --config extensions.mq= strip 1')
444 ...
445 ...
445 ... # shouldn't raise "7966c8e3734d: no node!"
446 ... # shouldn't raise "7966c8e3734d: no node!"
446 ... runcommand(server, ['branches'])
447 ... runcommand(server, ['branches'])
447 *** runcommand update -C 0
448 *** runcommand update -C 0
448 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
449 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
449 (leaving bookmark bm3)
450 (leaving bookmark bm3)
450 *** runcommand commit -Am. a
451 *** runcommand commit -Am. a
451 created new head
452 created new head
452 *** runcommand log -Gq
453 *** runcommand log -Gq
453 @ 5:731265503d86
454 @ 5:731265503d86
454 |
455 |
455 | o 4:7966c8e3734d
456 | o 4:7966c8e3734d
456 | |
457 | |
457 | o 3:b9b85890c400
458 | o 3:b9b85890c400
458 | |
459 | |
459 | o 2:aef17e88f5f0
460 | o 2:aef17e88f5f0
460 | |
461 | |
461 | o 1:d3a0a68be6de
462 | o 1:d3a0a68be6de
462 |/
463 |/
463 o 0:eff892de26ec
464 o 0:eff892de26ec
464
465
465 *** runcommand phase -p .
466 *** runcommand phase -p .
466 *** runcommand phase .
467 *** runcommand phase .
467 5: public
468 5: public
468 *** runcommand branches
469 *** runcommand branches
469 default 1:731265503d86
470 default 1:731265503d86
470
471
471 in-memory cache must be reloaded if transaction is aborted. otherwise
472 in-memory cache must be reloaded if transaction is aborted. otherwise
472 changelog and manifest would have invalid node:
473 changelog and manifest would have invalid node:
473
474
474 $ echo a >> a
475 $ echo a >> a
475 >>> from hgclient import readchannel, runcommand, check
476 >>> from hgclient import readchannel, runcommand, check
476 >>> @check
477 >>> @check
477 ... def txabort(server):
478 ... def txabort(server):
478 ... readchannel(server)
479 ... readchannel(server)
479 ... runcommand(server, ['commit', '--config', 'hooks.pretxncommit=false',
480 ... runcommand(server, ['commit', '--config', 'hooks.pretxncommit=false',
480 ... '-mfoo'])
481 ... '-mfoo'])
481 ... runcommand(server, ['verify'])
482 ... runcommand(server, ['verify'])
482 *** runcommand commit --config hooks.pretxncommit=false -mfoo
483 *** runcommand commit --config hooks.pretxncommit=false -mfoo
483 transaction abort!
484 transaction abort!
484 rollback completed
485 rollback completed
485 abort: pretxncommit hook exited with status 1
486 abort: pretxncommit hook exited with status 1
486 [255]
487 [255]
487 *** runcommand verify
488 *** runcommand verify
488 checking changesets
489 checking changesets
489 checking manifests
490 checking manifests
490 crosschecking files in changesets and manifests
491 crosschecking files in changesets and manifests
491 checking files
492 checking files
492 1 files, 2 changesets, 2 total revisions
493 1 files, 2 changesets, 2 total revisions
493 $ hg revert --no-backup -aq
494 $ hg revert --no-backup -aq
494
495
495 $ cat >> .hg/hgrc << EOF
496 $ cat >> .hg/hgrc << EOF
496 > [experimental]
497 > [experimental]
497 > evolution=createmarkers
498 > evolution=createmarkers
498 > EOF
499 > EOF
499
500
500 >>> import os
501 >>> import os
501 >>> from hgclient import readchannel, runcommand, check
502 >>> from hgclient import readchannel, runcommand, check
502 >>> @check
503 >>> @check
503 ... def obsolete(server):
504 ... def obsolete(server):
504 ... readchannel(server)
505 ... readchannel(server)
505 ...
506 ...
506 ... runcommand(server, ['up', 'null'])
507 ... runcommand(server, ['up', 'null'])
507 ... runcommand(server, ['phase', '-df', 'tip'])
508 ... runcommand(server, ['phase', '-df', 'tip'])
508 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
509 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
509 ... if os.name == 'nt':
510 ... if os.name == 'nt':
510 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
511 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
511 ... os.system(cmd)
512 ... os.system(cmd)
512 ... runcommand(server, ['log', '--hidden'])
513 ... runcommand(server, ['log', '--hidden'])
513 ... runcommand(server, ['log'])
514 ... runcommand(server, ['log'])
514 *** runcommand up null
515 *** runcommand up null
515 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
516 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
516 *** runcommand phase -df tip
517 *** runcommand phase -df tip
517 *** runcommand log --hidden
518 *** runcommand log --hidden
518 changeset: 1:731265503d86
519 changeset: 1:731265503d86
519 tag: tip
520 tag: tip
520 user: test
521 user: test
521 date: Thu Jan 01 00:00:00 1970 +0000
522 date: Thu Jan 01 00:00:00 1970 +0000
522 summary: .
523 summary: .
523
524
524 changeset: 0:eff892de26ec
525 changeset: 0:eff892de26ec
525 bookmark: bm1
526 bookmark: bm1
526 bookmark: bm2
527 bookmark: bm2
527 bookmark: bm3
528 bookmark: bm3
528 user: test
529 user: test
529 date: Thu Jan 01 00:00:00 1970 +0000
530 date: Thu Jan 01 00:00:00 1970 +0000
530 summary: 1
531 summary: 1
531
532
532 *** runcommand log
533 *** runcommand log
533 changeset: 0:eff892de26ec
534 changeset: 0:eff892de26ec
534 bookmark: bm1
535 bookmark: bm1
535 bookmark: bm2
536 bookmark: bm2
536 bookmark: bm3
537 bookmark: bm3
537 tag: tip
538 tag: tip
538 user: test
539 user: test
539 date: Thu Jan 01 00:00:00 1970 +0000
540 date: Thu Jan 01 00:00:00 1970 +0000
540 summary: 1
541 summary: 1
541
542
542
543
543 $ cat <<EOF >> .hg/hgrc
544 $ cat <<EOF >> .hg/hgrc
544 > [extensions]
545 > [extensions]
545 > mq =
546 > mq =
546 > EOF
547 > EOF
547
548
548 >>> import os
549 >>> import os
549 >>> from hgclient import readchannel, runcommand, check
550 >>> from hgclient import readchannel, runcommand, check
550 >>> @check
551 >>> @check
551 ... def mqoutsidechanges(server):
552 ... def mqoutsidechanges(server):
552 ... readchannel(server)
553 ... readchannel(server)
553 ...
554 ...
554 ... # load repo.mq
555 ... # load repo.mq
555 ... runcommand(server, ['qapplied'])
556 ... runcommand(server, ['qapplied'])
556 ... os.system('hg qnew 0.diff')
557 ... os.system('hg qnew 0.diff')
557 ... # repo.mq should be invalidated
558 ... # repo.mq should be invalidated
558 ... runcommand(server, ['qapplied'])
559 ... runcommand(server, ['qapplied'])
559 ...
560 ...
560 ... runcommand(server, ['qpop', '--all'])
561 ... runcommand(server, ['qpop', '--all'])
561 ... os.system('hg qqueue --create foo')
562 ... os.system('hg qqueue --create foo')
562 ... # repo.mq should be recreated to point to new queue
563 ... # repo.mq should be recreated to point to new queue
563 ... runcommand(server, ['qqueue', '--active'])
564 ... runcommand(server, ['qqueue', '--active'])
564 *** runcommand qapplied
565 *** runcommand qapplied
565 *** runcommand qapplied
566 *** runcommand qapplied
566 0.diff
567 0.diff
567 *** runcommand qpop --all
568 *** runcommand qpop --all
568 popping 0.diff
569 popping 0.diff
569 patch queue now empty
570 patch queue now empty
570 *** runcommand qqueue --active
571 *** runcommand qqueue --active
571 foo
572 foo
572
573
573 $ cat <<EOF > dbgui.py
574 $ cat <<EOF > dbgui.py
574 > import os, sys
575 > import os, sys
575 > from mercurial import commands, registrar
576 > from mercurial import commands, registrar
576 > cmdtable = {}
577 > cmdtable = {}
577 > command = registrar.command(cmdtable)
578 > command = registrar.command(cmdtable)
578 > @command(b"debuggetpass", norepo=True)
579 > @command(b"debuggetpass", norepo=True)
579 > def debuggetpass(ui):
580 > def debuggetpass(ui):
580 > ui.write("%s\\n" % ui.getpass())
581 > ui.write("%s\\n" % ui.getpass())
581 > @command(b"debugprompt", norepo=True)
582 > @command(b"debugprompt", norepo=True)
582 > def debugprompt(ui):
583 > def debugprompt(ui):
583 > ui.write("%s\\n" % ui.prompt("prompt:"))
584 > ui.write("%s\\n" % ui.prompt("prompt:"))
584 > @command(b"debugreadstdin", norepo=True)
585 > @command(b"debugreadstdin", norepo=True)
585 > def debugreadstdin(ui):
586 > def debugreadstdin(ui):
586 > ui.write("read: %r\n" % sys.stdin.read(1))
587 > ui.write("read: %r\n" % sys.stdin.read(1))
587 > @command(b"debugwritestdout", norepo=True)
588 > @command(b"debugwritestdout", norepo=True)
588 > def debugwritestdout(ui):
589 > def debugwritestdout(ui):
589 > os.write(1, "low-level stdout fd and\n")
590 > os.write(1, "low-level stdout fd and\n")
590 > sys.stdout.write("stdout should be redirected to /dev/null\n")
591 > sys.stdout.write("stdout should be redirected to /dev/null\n")
591 > sys.stdout.flush()
592 > sys.stdout.flush()
592 > EOF
593 > EOF
593 $ cat <<EOF >> .hg/hgrc
594 $ cat <<EOF >> .hg/hgrc
594 > [extensions]
595 > [extensions]
595 > dbgui = dbgui.py
596 > dbgui = dbgui.py
596 > EOF
597 > EOF
597
598
598 >>> from hgclient import readchannel, runcommand, check, stringio
599 >>> from hgclient import readchannel, runcommand, check, stringio
599 >>> @check
600 >>> @check
600 ... def getpass(server):
601 ... def getpass(server):
601 ... readchannel(server)
602 ... readchannel(server)
602 ... runcommand(server, ['debuggetpass', '--config',
603 ... runcommand(server, ['debuggetpass', '--config',
603 ... 'ui.interactive=True'],
604 ... 'ui.interactive=True'],
604 ... input=stringio('1234\n'))
605 ... input=stringio('1234\n'))
605 ... runcommand(server, ['debuggetpass', '--config',
606 ... runcommand(server, ['debuggetpass', '--config',
606 ... 'ui.interactive=True'],
607 ... 'ui.interactive=True'],
607 ... input=stringio('\n'))
608 ... input=stringio('\n'))
608 ... runcommand(server, ['debuggetpass', '--config',
609 ... runcommand(server, ['debuggetpass', '--config',
609 ... 'ui.interactive=True'],
610 ... 'ui.interactive=True'],
610 ... input=stringio(''))
611 ... input=stringio(''))
611 ... runcommand(server, ['debugprompt', '--config',
612 ... runcommand(server, ['debugprompt', '--config',
612 ... 'ui.interactive=True'],
613 ... 'ui.interactive=True'],
613 ... input=stringio('5678\n'))
614 ... input=stringio('5678\n'))
614 ... runcommand(server, ['debugreadstdin'])
615 ... runcommand(server, ['debugreadstdin'])
615 ... runcommand(server, ['debugwritestdout'])
616 ... runcommand(server, ['debugwritestdout'])
616 *** runcommand debuggetpass --config ui.interactive=True
617 *** runcommand debuggetpass --config ui.interactive=True
617 password: 1234
618 password: 1234
618 *** runcommand debuggetpass --config ui.interactive=True
619 *** runcommand debuggetpass --config ui.interactive=True
619 password:
620 password:
620 *** runcommand debuggetpass --config ui.interactive=True
621 *** runcommand debuggetpass --config ui.interactive=True
621 password: abort: response expected
622 password: abort: response expected
622 [255]
623 [255]
623 *** runcommand debugprompt --config ui.interactive=True
624 *** runcommand debugprompt --config ui.interactive=True
624 prompt: 5678
625 prompt: 5678
625 *** runcommand debugreadstdin
626 *** runcommand debugreadstdin
626 read: ''
627 read: ''
627 *** runcommand debugwritestdout
628 *** runcommand debugwritestdout
628
629
629
630
630 run commandserver in commandserver, which is silly but should work:
631 run commandserver in commandserver, which is silly but should work:
631
632
632 >>> from __future__ import print_function
633 >>> from __future__ import print_function
633 >>> from hgclient import readchannel, runcommand, check, stringio
634 >>> from hgclient import readchannel, runcommand, check, stringio
634 >>> @check
635 >>> @check
635 ... def nested(server):
636 ... def nested(server):
636 ... print('%c, %r' % readchannel(server))
637 ... print('%c, %r' % readchannel(server))
637 ... class nestedserver(object):
638 ... class nestedserver(object):
638 ... stdin = stringio('getencoding\n')
639 ... stdin = stringio('getencoding\n')
639 ... stdout = stringio()
640 ... stdout = stringio()
640 ... runcommand(server, ['serve', '--cmdserver', 'pipe'],
641 ... runcommand(server, ['serve', '--cmdserver', 'pipe'],
641 ... output=nestedserver.stdout, input=nestedserver.stdin)
642 ... output=nestedserver.stdout, input=nestedserver.stdin)
642 ... nestedserver.stdout.seek(0)
643 ... nestedserver.stdout.seek(0)
643 ... print('%c, %r' % readchannel(nestedserver)) # hello
644 ... print('%c, %r' % readchannel(nestedserver)) # hello
644 ... print('%c, %r' % readchannel(nestedserver)) # getencoding
645 ... print('%c, %r' % readchannel(nestedserver)) # getencoding
645 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
646 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
646 *** runcommand serve --cmdserver pipe
647 *** runcommand serve --cmdserver pipe
647 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
648 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
648 r, '*' (glob)
649 r, '*' (glob)
649
650
650
651
651 start without repository:
652 start without repository:
652
653
653 $ cd ..
654 $ cd ..
654
655
655 >>> from __future__ import print_function
656 >>> from __future__ import print_function
656 >>> from hgclient import readchannel, runcommand, check
657 >>> from hgclient import readchannel, runcommand, check
657 >>> @check
658 >>> @check
658 ... def hellomessage(server):
659 ... def hellomessage(server):
659 ... ch, data = readchannel(server)
660 ... ch, data = readchannel(server)
660 ... print('%c, %r' % (ch, data))
661 ... print('%c, %r' % (ch, data))
661 ... # run an arbitrary command to make sure the next thing the server
662 ... # run an arbitrary command to make sure the next thing the server
662 ... # sends isn't part of the hello message
663 ... # sends isn't part of the hello message
663 ... runcommand(server, ['id'])
664 ... runcommand(server, ['id'])
664 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
665 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
665 *** runcommand id
666 *** runcommand id
666 abort: there is no Mercurial repository here (.hg not found)
667 abort: there is no Mercurial repository here (.hg not found)
667 [255]
668 [255]
668
669
669 >>> from hgclient import readchannel, runcommand, check
670 >>> from hgclient import readchannel, runcommand, check
670 >>> @check
671 >>> @check
671 ... def startwithoutrepo(server):
672 ... def startwithoutrepo(server):
672 ... readchannel(server)
673 ... readchannel(server)
673 ... runcommand(server, ['init', 'repo2'])
674 ... runcommand(server, ['init', 'repo2'])
674 ... runcommand(server, ['id', '-R', 'repo2'])
675 ... runcommand(server, ['id', '-R', 'repo2'])
675 *** runcommand init repo2
676 *** runcommand init repo2
676 *** runcommand id -R repo2
677 *** runcommand id -R repo2
677 000000000000 tip
678 000000000000 tip
678
679
679
680
680 don't fall back to cwd if invalid -R path is specified (issue4805):
681 don't fall back to cwd if invalid -R path is specified (issue4805):
681
682
682 $ cd repo
683 $ cd repo
683 $ hg serve --cmdserver pipe -R ../nonexistent
684 $ hg serve --cmdserver pipe -R ../nonexistent
684 abort: repository ../nonexistent not found!
685 abort: repository ../nonexistent not found!
685 [255]
686 [255]
686 $ cd ..
687 $ cd ..
687
688
688
689
689 unix domain socket:
690 unix domain socket:
690
691
691 $ cd repo
692 $ cd repo
692 $ hg update -q
693 $ hg update -q
693
694
694 #if unix-socket unix-permissions
695 #if unix-socket unix-permissions
695
696
696 >>> from __future__ import print_function
697 >>> from __future__ import print_function
697 >>> from hgclient import unixserver, readchannel, runcommand, check, stringio
698 >>> from hgclient import unixserver, readchannel, runcommand, check, stringio
698 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
699 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
699 >>> def hellomessage(conn):
700 >>> def hellomessage(conn):
700 ... ch, data = readchannel(conn)
701 ... ch, data = readchannel(conn)
701 ... print('%c, %r' % (ch, data))
702 ... print('%c, %r' % (ch, data))
702 ... runcommand(conn, ['id'])
703 ... runcommand(conn, ['id'])
703 >>> check(hellomessage, server.connect)
704 >>> check(hellomessage, server.connect)
704 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
705 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
705 *** runcommand id
706 *** runcommand id
706 eff892de26ec tip bm1/bm2/bm3
707 eff892de26ec tip bm1/bm2/bm3
707 >>> def unknowncommand(conn):
708 >>> def unknowncommand(conn):
708 ... readchannel(conn)
709 ... readchannel(conn)
709 ... conn.stdin.write('unknowncommand\n')
710 ... conn.stdin.write('unknowncommand\n')
710 >>> check(unknowncommand, server.connect) # error sent to server.log
711 >>> check(unknowncommand, server.connect) # error sent to server.log
711 >>> def serverinput(conn):
712 >>> def serverinput(conn):
712 ... readchannel(conn)
713 ... readchannel(conn)
713 ... patch = """
714 ... patch = """
714 ... # HG changeset patch
715 ... # HG changeset patch
715 ... # User test
716 ... # User test
716 ... # Date 0 0
717 ... # Date 0 0
717 ... 2
718 ... 2
718 ...
719 ...
719 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
720 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
720 ... --- a/a
721 ... --- a/a
721 ... +++ b/a
722 ... +++ b/a
722 ... @@ -1,1 +1,2 @@
723 ... @@ -1,1 +1,2 @@
723 ... 1
724 ... 1
724 ... +2
725 ... +2
725 ... """
726 ... """
726 ... runcommand(conn, ['import', '-'], input=stringio(patch))
727 ... runcommand(conn, ['import', '-'], input=stringio(patch))
727 ... runcommand(conn, ['log', '-rtip', '-q'])
728 ... runcommand(conn, ['log', '-rtip', '-q'])
728 >>> check(serverinput, server.connect)
729 >>> check(serverinput, server.connect)
729 *** runcommand import -
730 *** runcommand import -
730 applying patch from stdin
731 applying patch from stdin
731 *** runcommand log -rtip -q
732 *** runcommand log -rtip -q
732 2:1ed24be7e7a0
733 2:1ed24be7e7a0
733 >>> server.shutdown()
734 >>> server.shutdown()
734
735
735 $ cat .hg/server.log
736 $ cat .hg/server.log
736 listening at .hg/server.sock
737 listening at .hg/server.sock
737 abort: unknown command unknowncommand
738 abort: unknown command unknowncommand
738 killed!
739 killed!
739 $ rm .hg/server.log
740 $ rm .hg/server.log
740
741
741 if server crashed before hello, traceback will be sent to 'e' channel as
742 if server crashed before hello, traceback will be sent to 'e' channel as
742 last ditch:
743 last ditch:
743
744
744 $ cat <<EOF >> .hg/hgrc
745 $ cat <<EOF >> .hg/hgrc
745 > [cmdserver]
746 > [cmdserver]
746 > log = inexistent/path.log
747 > log = inexistent/path.log
747 > EOF
748 > EOF
748 >>> from __future__ import print_function
749 >>> from __future__ import print_function
749 >>> from hgclient import unixserver, readchannel, check
750 >>> from hgclient import unixserver, readchannel, check
750 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
751 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
751 >>> def earlycrash(conn):
752 >>> def earlycrash(conn):
752 ... while True:
753 ... while True:
753 ... try:
754 ... try:
754 ... ch, data = readchannel(conn)
755 ... ch, data = readchannel(conn)
755 ... if not data.startswith(' '):
756 ... if not data.startswith(' '):
756 ... print('%c, %r' % (ch, data))
757 ... print('%c, %r' % (ch, data))
757 ... except EOFError:
758 ... except EOFError:
758 ... break
759 ... break
759 >>> check(earlycrash, server.connect)
760 >>> check(earlycrash, server.connect)
760 e, 'Traceback (most recent call last):\n'
761 e, 'Traceback (most recent call last):\n'
761 e, "IOError: *" (glob)
762 e, "IOError: *" (glob)
762 >>> server.shutdown()
763 >>> server.shutdown()
763
764
764 $ cat .hg/server.log | grep -v '^ '
765 $ cat .hg/server.log | grep -v '^ '
765 listening at .hg/server.sock
766 listening at .hg/server.sock
766 Traceback (most recent call last):
767 Traceback (most recent call last):
767 IOError: * (glob)
768 IOError: * (glob)
768 killed!
769 killed!
769 #endif
770 #endif
770 #if no-unix-socket
771 #if no-unix-socket
771
772
772 $ hg serve --cmdserver unix -a .hg/server.sock
773 $ hg serve --cmdserver unix -a .hg/server.sock
773 abort: unsupported platform
774 abort: unsupported platform
774 [255]
775 [255]
775
776
776 #endif
777 #endif
777
778
778 $ cd ..
779 $ cd ..
779
780
780 Test that accessing to invalid changelog cache is avoided at
781 Test that accessing to invalid changelog cache is avoided at
781 subsequent operations even if repo object is reused even after failure
782 subsequent operations even if repo object is reused even after failure
782 of transaction (see 0a7610758c42 also)
783 of transaction (see 0a7610758c42 also)
783
784
784 "hg log" after failure of transaction is needed to detect invalid
785 "hg log" after failure of transaction is needed to detect invalid
785 cache in repoview: this can't detect by "hg verify" only.
786 cache in repoview: this can't detect by "hg verify" only.
786
787
787 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
788 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
788 4) are tested, because '00changelog.i' are differently changed in each
789 4) are tested, because '00changelog.i' are differently changed in each
789 cases.
790 cases.
790
791
791 $ cat > $TESTTMP/failafterfinalize.py <<EOF
792 $ cat > $TESTTMP/failafterfinalize.py <<EOF
792 > # extension to abort transaction after finalization forcibly
793 > # extension to abort transaction after finalization forcibly
793 > from mercurial import commands, error, extensions, lock as lockmod
794 > from mercurial import commands, error, extensions, lock as lockmod
794 > def fail(tr):
795 > def fail(tr):
795 > raise error.Abort('fail after finalization')
796 > raise error.Abort('fail after finalization')
796 > def reposetup(ui, repo):
797 > def reposetup(ui, repo):
797 > class failrepo(repo.__class__):
798 > class failrepo(repo.__class__):
798 > def commitctx(self, ctx, error=False):
799 > def commitctx(self, ctx, error=False):
799 > if self.ui.configbool('failafterfinalize', 'fail'):
800 > if self.ui.configbool('failafterfinalize', 'fail'):
800 > # 'sorted()' by ASCII code on category names causes
801 > # 'sorted()' by ASCII code on category names causes
801 > # invoking 'fail' after finalization of changelog
802 > # invoking 'fail' after finalization of changelog
802 > # using "'cl-%i' % id(self)" as category name
803 > # using "'cl-%i' % id(self)" as category name
803 > self.currenttransaction().addfinalize('zzzzzzzz', fail)
804 > self.currenttransaction().addfinalize('zzzzzzzz', fail)
804 > return super(failrepo, self).commitctx(ctx, error)
805 > return super(failrepo, self).commitctx(ctx, error)
805 > repo.__class__ = failrepo
806 > repo.__class__ = failrepo
806 > EOF
807 > EOF
807
808
808 $ hg init repo3
809 $ hg init repo3
809 $ cd repo3
810 $ cd repo3
810
811
811 $ cat <<EOF >> $HGRCPATH
812 $ cat <<EOF >> $HGRCPATH
812 > [ui]
813 > [ui]
813 > logtemplate = {rev} {desc|firstline} ({files})\n
814 > logtemplate = {rev} {desc|firstline} ({files})\n
814 >
815 >
815 > [extensions]
816 > [extensions]
816 > failafterfinalize = $TESTTMP/failafterfinalize.py
817 > failafterfinalize = $TESTTMP/failafterfinalize.py
817 > EOF
818 > EOF
818
819
819 - test failure with "empty changelog"
820 - test failure with "empty changelog"
820
821
821 $ echo foo > foo
822 $ echo foo > foo
822 $ hg add foo
823 $ hg add foo
823
824
824 (failure before finalization)
825 (failure before finalization)
825
826
826 >>> from hgclient import readchannel, runcommand, check
827 >>> from hgclient import readchannel, runcommand, check
827 >>> @check
828 >>> @check
828 ... def abort(server):
829 ... def abort(server):
829 ... readchannel(server)
830 ... readchannel(server)
830 ... runcommand(server, ['commit',
831 ... runcommand(server, ['commit',
831 ... '--config', 'hooks.pretxncommit=false',
832 ... '--config', 'hooks.pretxncommit=false',
832 ... '-mfoo'])
833 ... '-mfoo'])
833 ... runcommand(server, ['log'])
834 ... runcommand(server, ['log'])
834 ... runcommand(server, ['verify', '-q'])
835 ... runcommand(server, ['verify', '-q'])
835 *** runcommand commit --config hooks.pretxncommit=false -mfoo
836 *** runcommand commit --config hooks.pretxncommit=false -mfoo
836 transaction abort!
837 transaction abort!
837 rollback completed
838 rollback completed
838 abort: pretxncommit hook exited with status 1
839 abort: pretxncommit hook exited with status 1
839 [255]
840 [255]
840 *** runcommand log
841 *** runcommand log
841 *** runcommand verify -q
842 *** runcommand verify -q
842
843
843 (failure after finalization)
844 (failure after finalization)
844
845
845 >>> from hgclient import readchannel, runcommand, check
846 >>> from hgclient import readchannel, runcommand, check
846 >>> @check
847 >>> @check
847 ... def abort(server):
848 ... def abort(server):
848 ... readchannel(server)
849 ... readchannel(server)
849 ... runcommand(server, ['commit',
850 ... runcommand(server, ['commit',
850 ... '--config', 'failafterfinalize.fail=true',
851 ... '--config', 'failafterfinalize.fail=true',
851 ... '-mfoo'])
852 ... '-mfoo'])
852 ... runcommand(server, ['log'])
853 ... runcommand(server, ['log'])
853 ... runcommand(server, ['verify', '-q'])
854 ... runcommand(server, ['verify', '-q'])
854 *** runcommand commit --config failafterfinalize.fail=true -mfoo
855 *** runcommand commit --config failafterfinalize.fail=true -mfoo
855 transaction abort!
856 transaction abort!
856 rollback completed
857 rollback completed
857 abort: fail after finalization
858 abort: fail after finalization
858 [255]
859 [255]
859 *** runcommand log
860 *** runcommand log
860 *** runcommand verify -q
861 *** runcommand verify -q
861
862
862 - test failure with "not-empty changelog"
863 - test failure with "not-empty changelog"
863
864
864 $ echo bar > bar
865 $ echo bar > bar
865 $ hg add bar
866 $ hg add bar
866 $ hg commit -mbar bar
867 $ hg commit -mbar bar
867
868
868 (failure before finalization)
869 (failure before finalization)
869
870
870 >>> from hgclient import readchannel, runcommand, check
871 >>> from hgclient import readchannel, runcommand, check
871 >>> @check
872 >>> @check
872 ... def abort(server):
873 ... def abort(server):
873 ... readchannel(server)
874 ... readchannel(server)
874 ... runcommand(server, ['commit',
875 ... runcommand(server, ['commit',
875 ... '--config', 'hooks.pretxncommit=false',
876 ... '--config', 'hooks.pretxncommit=false',
876 ... '-mfoo', 'foo'])
877 ... '-mfoo', 'foo'])
877 ... runcommand(server, ['log'])
878 ... runcommand(server, ['log'])
878 ... runcommand(server, ['verify', '-q'])
879 ... runcommand(server, ['verify', '-q'])
879 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
880 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
880 transaction abort!
881 transaction abort!
881 rollback completed
882 rollback completed
882 abort: pretxncommit hook exited with status 1
883 abort: pretxncommit hook exited with status 1
883 [255]
884 [255]
884 *** runcommand log
885 *** runcommand log
885 0 bar (bar)
886 0 bar (bar)
886 *** runcommand verify -q
887 *** runcommand verify -q
887
888
888 (failure after finalization)
889 (failure after finalization)
889
890
890 >>> from hgclient import readchannel, runcommand, check
891 >>> from hgclient import readchannel, runcommand, check
891 >>> @check
892 >>> @check
892 ... def abort(server):
893 ... def abort(server):
893 ... readchannel(server)
894 ... readchannel(server)
894 ... runcommand(server, ['commit',
895 ... runcommand(server, ['commit',
895 ... '--config', 'failafterfinalize.fail=true',
896 ... '--config', 'failafterfinalize.fail=true',
896 ... '-mfoo', 'foo'])
897 ... '-mfoo', 'foo'])
897 ... runcommand(server, ['log'])
898 ... runcommand(server, ['log'])
898 ... runcommand(server, ['verify', '-q'])
899 ... runcommand(server, ['verify', '-q'])
899 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
900 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
900 transaction abort!
901 transaction abort!
901 rollback completed
902 rollback completed
902 abort: fail after finalization
903 abort: fail after finalization
903 [255]
904 [255]
904 *** runcommand log
905 *** runcommand log
905 0 bar (bar)
906 0 bar (bar)
906 *** runcommand verify -q
907 *** runcommand verify -q
General Comments 0
You need to be logged in to leave comments. Login now