author | Lucas Moscovicz <lmoscovicz@fb.com> |
Fri, 07 Mar 2014 13:48:31 -0800 | |
changeset 20694 | 621c94378d0d |
parent 20650 | e811b93f2cb1 |
child 21195 | 9336bc7dca8e |
permissions | -rw-r--r-- |
14882
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
1 |
import sys, os, struct, subprocess, cStringIO, re, shutil |
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 |
def connect(path=None): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 |
cmdline = ['hg', 'serve', '--cmdserver', 'pipe'] |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 |
if path: |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 |
cmdline += ['-R', path] |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 |
server = subprocess.Popen(cmdline, stdin=subprocess.PIPE, |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 |
stdout=subprocess.PIPE) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
10 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
11 |
return server |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
12 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 |
def writeblock(server, data): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 |
server.stdin.write(struct.pack('>I', len(data))) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
15 |
server.stdin.write(data) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 |
server.stdin.flush() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
17 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
18 |
def readchannel(server): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
19 |
data = server.stdout.read(5) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
20 |
if not data: |
16687
e34106fa0dc3
cleanup: "raise SomeException()" -> "raise SomeException"
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
21 |
raise EOFError |
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
22 |
channel, length = struct.unpack('>cI', data) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
23 |
if channel in 'IL': |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
24 |
return channel, length |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
25 |
else: |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
26 |
return channel, server.stdout.read(length) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
27 |
|
19132
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
28 |
def sep(text): |
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
29 |
return text.replace('\\', '/') |
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
30 |
|
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
31 |
def runcommand(server, args, output=sys.stdout, error=sys.stderr, input=None, |
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
32 |
outfilter=lambda x: x): |
15541
3aee6e26b28b
tests: make test-commandserver.py output readable
Mads Kiilerich <mads@kiilerich.com>
parents:
14939
diff
changeset
|
33 |
print ' runcommand', ' '.join(args) |
16117
6ecf5fb2a475
test-commandserver: flush stdout
Idan Kamara <idankk86@gmail.com>
parents:
16116
diff
changeset
|
34 |
sys.stdout.flush() |
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
35 |
server.stdin.write('runcommand\n') |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
36 |
writeblock(server, '\0'.join(args)) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
37 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
38 |
if not input: |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
39 |
input = cStringIO.StringIO() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
40 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
41 |
while True: |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
42 |
ch, data = readchannel(server) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
43 |
if ch == 'o': |
19132
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
44 |
output.write(outfilter(data)) |
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
45 |
output.flush() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
46 |
elif ch == 'e': |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
47 |
error.write(data) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
48 |
error.flush() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
49 |
elif ch == 'I': |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
50 |
writeblock(server, input.read(data)) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
51 |
elif ch == 'L': |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
52 |
writeblock(server, input.readline(data)) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
53 |
elif ch == 'r': |
20630
0b04ee8e789d
cmdserver: include non-zero return code of runcommand in test output
Yuya Nishihara <yuya@tcha.org>
parents:
20629
diff
changeset
|
54 |
ret, = struct.unpack('>i', data) |
0b04ee8e789d
cmdserver: include non-zero return code of runcommand in test output
Yuya Nishihara <yuya@tcha.org>
parents:
20629
diff
changeset
|
55 |
if ret != 0: |
0b04ee8e789d
cmdserver: include non-zero return code of runcommand in test output
Yuya Nishihara <yuya@tcha.org>
parents:
20629
diff
changeset
|
56 |
print ' [%d]' % ret |
0b04ee8e789d
cmdserver: include non-zero return code of runcommand in test output
Yuya Nishihara <yuya@tcha.org>
parents:
20629
diff
changeset
|
57 |
return ret |
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
58 |
else: |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
59 |
print "unexpected channel %c: %r" % (ch, data) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
60 |
if ch.isupper(): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
61 |
return |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
62 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
63 |
def check(func, repopath=None): |
15541
3aee6e26b28b
tests: make test-commandserver.py output readable
Mads Kiilerich <mads@kiilerich.com>
parents:
14939
diff
changeset
|
64 |
|
3aee6e26b28b
tests: make test-commandserver.py output readable
Mads Kiilerich <mads@kiilerich.com>
parents:
14939
diff
changeset
|
65 |
print 'testing %s:' % func.__name__ |
3aee6e26b28b
tests: make test-commandserver.py output readable
Mads Kiilerich <mads@kiilerich.com>
parents:
14939
diff
changeset
|
66 |
|
16117
6ecf5fb2a475
test-commandserver: flush stdout
Idan Kamara <idankk86@gmail.com>
parents:
16116
diff
changeset
|
67 |
sys.stdout.flush() |
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
68 |
server = connect(repopath) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
69 |
try: |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
70 |
return func(server) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
71 |
finally: |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
72 |
server.stdin.close() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
73 |
server.wait() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
74 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
75 |
def unknowncommand(server): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
76 |
server.stdin.write('unknowncommand\n') |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
77 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
78 |
def hellomessage(server): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
79 |
ch, data = readchannel(server) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
80 |
# escaping python tests output not supported |
16683 | 81 |
print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', |
82 |
data)) |
|
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
83 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
84 |
# run an arbitrary command to make sure the next thing the server sends |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
85 |
# isn't part of the hello message |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
86 |
runcommand(server, ['id']) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
87 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
88 |
def checkruncommand(server): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
89 |
# hello block |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
90 |
readchannel(server) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
91 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
92 |
# no args |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
93 |
runcommand(server, []) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
94 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
95 |
# global options |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
96 |
runcommand(server, ['id', '--quiet']) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
97 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
98 |
# make sure global options don't stick through requests |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
99 |
runcommand(server, ['id']) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
100 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
101 |
# --config |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
102 |
runcommand(server, ['id', '--config', 'ui.quiet=True']) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
103 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
104 |
# make sure --config doesn't stick |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
105 |
runcommand(server, ['id']) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
106 |
|
20631
5d4606bec54c
cmdserver: mask return code of runcommand in the same way as dispatch.run
Yuya Nishihara <yuya@tcha.org>
parents:
20630
diff
changeset
|
107 |
# negative return code should be masked |
5d4606bec54c
cmdserver: mask return code of runcommand in the same way as dispatch.run
Yuya Nishihara <yuya@tcha.org>
parents:
20630
diff
changeset
|
108 |
runcommand(server, ['id', '-runknown']) |
5d4606bec54c
cmdserver: mask return code of runcommand in the same way as dispatch.run
Yuya Nishihara <yuya@tcha.org>
parents:
20630
diff
changeset
|
109 |
|
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
110 |
def inputeof(server): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
111 |
readchannel(server) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
112 |
server.stdin.write('runcommand\n') |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
113 |
# close stdin while server is waiting for input |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
114 |
server.stdin.close() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
115 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
116 |
# server exits with 1 if the pipe closed while reading the command |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
117 |
print 'server exit code =', server.wait() |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
118 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
119 |
def serverinput(server): |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
120 |
readchannel(server) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
121 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
122 |
patch = """ |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
123 |
# HG changeset patch |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
124 |
# User test |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
125 |
# Date 0 0 |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
126 |
# Node ID c103a3dec114d882c98382d684d8af798d09d857 |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
127 |
# Parent 0000000000000000000000000000000000000000 |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
128 |
1 |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
129 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
130 |
diff -r 000000000000 -r c103a3dec114 a |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
131 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
132 |
+++ b/a Thu Jan 01 00:00:00 1970 +0000 |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
133 |
@@ -0,0 +1,1 @@ |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
134 |
+1 |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
135 |
""" |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
136 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
137 |
runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch)) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
138 |
runcommand(server, ['log']) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
139 |
|
14864
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
140 |
def cwd(server): |
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
141 |
""" check that --cwd doesn't persist between requests """ |
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
142 |
readchannel(server) |
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
143 |
os.mkdir('foo') |
15542
e19302598df8
tests: make test-commandserver.py independent of line ending and slash direction
Mads Kiilerich <mads@kiilerich.com>
parents:
15541
diff
changeset
|
144 |
f = open('foo/bar', 'wb') |
14880
5233df79deed
test-commandserver: explicitly close opened file
Idan Kamara <idankk86@gmail.com>
parents:
14864
diff
changeset
|
145 |
f.write('a') |
5233df79deed
test-commandserver: explicitly close opened file
Idan Kamara <idankk86@gmail.com>
parents:
14864
diff
changeset
|
146 |
f.close() |
14864
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
147 |
runcommand(server, ['--cwd', 'foo', 'st', 'bar']) |
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
148 |
runcommand(server, ['st', 'foo/bar']) |
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
149 |
os.remove('foo/bar') |
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
150 |
|
14882
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
151 |
def localhgrc(server): |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
152 |
""" check that local configs for the cached repo aren't inherited when -R |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
153 |
is used """ |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
154 |
readchannel(server) |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
155 |
|
16683 | 156 |
# the cached repo local hgrc contains ui.foo=bar, so showconfig should |
157 |
# show it |
|
14882
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
158 |
runcommand(server, ['showconfig']) |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
159 |
|
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
160 |
# but not for this repo |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
161 |
runcommand(server, ['init', 'foo']) |
15542
e19302598df8
tests: make test-commandserver.py independent of line ending and slash direction
Mads Kiilerich <mads@kiilerich.com>
parents:
15541
diff
changeset
|
162 |
runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults']) |
14882
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
163 |
shutil.rmtree('foo') |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
164 |
|
14889
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
165 |
def hook(**args): |
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
166 |
print 'hook talking' |
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
167 |
print 'now try to read something: %r' % sys.stdin.read() |
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
168 |
|
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
169 |
def hookoutput(server): |
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
170 |
readchannel(server) |
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
171 |
runcommand(server, ['--config', |
16683 | 172 |
'hooks.pre-identify=python:test-commandserver.hook', |
173 |
'id'], |
|
14889
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
174 |
input=cStringIO.StringIO('some input')) |
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
175 |
|
14939
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
176 |
def outsidechanges(server): |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
177 |
readchannel(server) |
15542
e19302598df8
tests: make test-commandserver.py independent of line ending and slash direction
Mads Kiilerich <mads@kiilerich.com>
parents:
15541
diff
changeset
|
178 |
f = open('a', 'ab') |
e19302598df8
tests: make test-commandserver.py independent of line ending and slash direction
Mads Kiilerich <mads@kiilerich.com>
parents:
15541
diff
changeset
|
179 |
f.write('a\n') |
e19302598df8
tests: make test-commandserver.py independent of line ending and slash direction
Mads Kiilerich <mads@kiilerich.com>
parents:
15541
diff
changeset
|
180 |
f.close() |
16114
acfca07a8f26
cmdserver: invalidate the dirstate when running commands (issue3271)
Idan Kamara <idankk86@gmail.com>
parents:
15989
diff
changeset
|
181 |
runcommand(server, ['status']) |
15542
e19302598df8
tests: make test-commandserver.py independent of line ending and slash direction
Mads Kiilerich <mads@kiilerich.com>
parents:
15541
diff
changeset
|
182 |
os.system('hg ci -Am2') |
14939
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
183 |
runcommand(server, ['tip']) |
16114
acfca07a8f26
cmdserver: invalidate the dirstate when running commands (issue3271)
Idan Kamara <idankk86@gmail.com>
parents:
15989
diff
changeset
|
184 |
runcommand(server, ['status']) |
14939
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
185 |
|
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
186 |
def bookmarks(server): |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
187 |
readchannel(server) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
188 |
runcommand(server, ['bookmarks']) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
189 |
|
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
190 |
# changes .hg/bookmarks |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
191 |
os.system('hg bookmark -i bm1') |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
192 |
os.system('hg bookmark -i bm2') |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
193 |
runcommand(server, ['bookmarks']) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
194 |
|
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
195 |
# changes .hg/bookmarks.current |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
196 |
os.system('hg upd bm1 -q') |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
197 |
runcommand(server, ['bookmarks']) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
198 |
|
16115
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
16114
diff
changeset
|
199 |
runcommand(server, ['bookmarks', 'bm3']) |
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
16114
diff
changeset
|
200 |
f = open('a', 'ab') |
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
16114
diff
changeset
|
201 |
f.write('a\n') |
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
16114
diff
changeset
|
202 |
f.close() |
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
16114
diff
changeset
|
203 |
runcommand(server, ['commit', '-Amm']) |
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
16114
diff
changeset
|
204 |
runcommand(server, ['bookmarks']) |
236bb604dc39
scmutil: update cached copy when filecached attribute is assigned (issue3263)
Idan Kamara <idankk86@gmail.com>
parents:
16114
diff
changeset
|
205 |
|
14939
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
206 |
def tagscache(server): |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
207 |
readchannel(server) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
208 |
runcommand(server, ['id', '-t', '-r', '0']) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
209 |
os.system('hg tag -r 0 foo') |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
210 |
runcommand(server, ['id', '-t', '-r', '0']) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
211 |
|
15989
6548a2e32285
test-commandserver: test that phase data is being refreshed
Idan Kamara <idankk86@gmail.com>
parents:
15542
diff
changeset
|
212 |
def setphase(server): |
6548a2e32285
test-commandserver: test that phase data is being refreshed
Idan Kamara <idankk86@gmail.com>
parents:
15542
diff
changeset
|
213 |
readchannel(server) |
6548a2e32285
test-commandserver: test that phase data is being refreshed
Idan Kamara <idankk86@gmail.com>
parents:
15542
diff
changeset
|
214 |
runcommand(server, ['phase', '-r', '.']) |
6548a2e32285
test-commandserver: test that phase data is being refreshed
Idan Kamara <idankk86@gmail.com>
parents:
15542
diff
changeset
|
215 |
os.system('hg phase -r . -p') |
6548a2e32285
test-commandserver: test that phase data is being refreshed
Idan Kamara <idankk86@gmail.com>
parents:
15542
diff
changeset
|
216 |
runcommand(server, ['phase', '-r', '.']) |
6548a2e32285
test-commandserver: test that phase data is being refreshed
Idan Kamara <idankk86@gmail.com>
parents:
15542
diff
changeset
|
217 |
|
16116
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
218 |
def rollback(server): |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
219 |
readchannel(server) |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
220 |
runcommand(server, ['phase', '-r', '.', '-p']) |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
221 |
f = open('a', 'ab') |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
222 |
f.write('a\n') |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
223 |
f.close() |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
224 |
runcommand(server, ['commit', '-Am.']) |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
225 |
runcommand(server, ['rollback']) |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
226 |
runcommand(server, ['phase', '-r', '.']) |
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
227 |
|
16201
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
228 |
def branch(server): |
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
229 |
readchannel(server) |
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
230 |
runcommand(server, ['branch']) |
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
231 |
os.system('hg branch foo') |
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
232 |
runcommand(server, ['branch']) |
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
233 |
os.system('hg branch default') |
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
234 |
|
16202
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
235 |
def hgignore(server): |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
236 |
readchannel(server) |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
237 |
f = open('.hgignore', 'ab') |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
238 |
f.write('') |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
239 |
f.close() |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
240 |
runcommand(server, ['commit', '-Am.']) |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
241 |
f = open('ignored-file', 'ab') |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
242 |
f.write('') |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
243 |
f.close() |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
244 |
f = open('.hgignore', 'ab') |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
245 |
f.write('ignored-file') |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
246 |
f.close() |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
247 |
runcommand(server, ['status', '-i', '-u']) |
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
248 |
|
18757
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
249 |
def phasecacheafterstrip(server): |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
250 |
readchannel(server) |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
251 |
|
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
252 |
# create new head, 5:731265503d86 |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
253 |
runcommand(server, ['update', '-C', '0']) |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
254 |
f = open('a', 'ab') |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
255 |
f.write('a\n') |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
256 |
f.close() |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
257 |
runcommand(server, ['commit', '-Am.', 'a']) |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
258 |
runcommand(server, ['log', '-Gq']) |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
259 |
|
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
260 |
# make it public; draft marker moves to 4:7966c8e3734d |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
261 |
runcommand(server, ['phase', '-p', '.']) |
19132
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
262 |
# load _phasecache.phaseroots |
605deb776abf
tests: fix test-commandserver phase . output for windows
Brendan Cully <brendan@kublai.com>
parents:
18757
diff
changeset
|
263 |
runcommand(server, ['phase', '.'], outfilter=sep) |
18757
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
264 |
|
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
265 |
# strip 1::4 outside server |
19166
e958b17696fe
tests: quiet strip to avoid commandserver pathsep issue
Matt Mackall <mpm@selenic.com>
parents:
18757
diff
changeset
|
266 |
os.system('hg -q --config extensions.mq= strip 1') |
18757
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
267 |
|
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
268 |
# shouldn't raise "7966c8e3734d: no node!" |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
269 |
runcommand(server, ['branches']) |
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
270 |
|
20330
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
271 |
def obsolete(server): |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
272 |
readchannel(server) |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
273 |
|
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
274 |
runcommand(server, ['up', 'null']) |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
275 |
runcommand(server, ['phase', '-df', 'tip']) |
20396
a8e6ab7eb361
tests: on windows, run command explicitly in sh for working command substitution
Simon Heimberg <simohe@besonet.ch>
parents:
20330
diff
changeset
|
276 |
cmd = 'hg debugobsolete `hg log -r tip --template {node}`' |
a8e6ab7eb361
tests: on windows, run command explicitly in sh for working command substitution
Simon Heimberg <simohe@besonet.ch>
parents:
20330
diff
changeset
|
277 |
if os.name == 'nt': |
a8e6ab7eb361
tests: on windows, run command explicitly in sh for working command substitution
Simon Heimberg <simohe@besonet.ch>
parents:
20330
diff
changeset
|
278 |
cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe |
a8e6ab7eb361
tests: on windows, run command explicitly in sh for working command substitution
Simon Heimberg <simohe@besonet.ch>
parents:
20330
diff
changeset
|
279 |
os.system(cmd) |
20330
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
280 |
runcommand(server, ['log', '--hidden']) |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
281 |
runcommand(server, ['log']) |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
282 |
|
20628
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
283 |
def mqoutsidechanges(server): |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
284 |
readchannel(server) |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
285 |
|
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
286 |
# load repo.mq |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
287 |
runcommand(server, ['qapplied']) |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
288 |
os.system('hg qnew 0.diff') |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
289 |
# repo.mq should be invalidated |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
290 |
runcommand(server, ['qapplied']) |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
291 |
|
20629
277dc5f27310
cmdserver: recreate mq object on runcommand in case queue path was changed
Yuya Nishihara <yuya@tcha.org>
parents:
20628
diff
changeset
|
292 |
runcommand(server, ['qpop', '--all']) |
277dc5f27310
cmdserver: recreate mq object on runcommand in case queue path was changed
Yuya Nishihara <yuya@tcha.org>
parents:
20628
diff
changeset
|
293 |
os.system('hg qqueue --create foo') |
277dc5f27310
cmdserver: recreate mq object on runcommand in case queue path was changed
Yuya Nishihara <yuya@tcha.org>
parents:
20628
diff
changeset
|
294 |
# repo.mq should be recreated to point to new queue |
277dc5f27310
cmdserver: recreate mq object on runcommand in case queue path was changed
Yuya Nishihara <yuya@tcha.org>
parents:
20628
diff
changeset
|
295 |
runcommand(server, ['qqueue', '--active']) |
277dc5f27310
cmdserver: recreate mq object on runcommand in case queue path was changed
Yuya Nishihara <yuya@tcha.org>
parents:
20628
diff
changeset
|
296 |
|
20650
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
297 |
def startwithoutrepo(server): |
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
298 |
readchannel(server) |
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
299 |
runcommand(server, ['init', 'repo2']) |
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
300 |
runcommand(server, ['id', '-R', 'repo2']) |
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
301 |
|
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
302 |
if __name__ == '__main__': |
20649
9524938c8ff8
cmdserver: prepare test for starting server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20631
diff
changeset
|
303 |
os.system('hg init repo') |
9524938c8ff8
cmdserver: prepare test for starting server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20631
diff
changeset
|
304 |
os.chdir('repo') |
14770
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
305 |
|
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
306 |
check(hellomessage) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
307 |
check(unknowncommand) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
308 |
check(checkruncommand) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
309 |
check(inputeof) |
95a8c0f5dd3f
tests: add basic commandserver test
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
310 |
check(serverinput) |
14864
1b872599f39f
cmdserver: restore old working dir after dispatch when we have --cwd
Idan Kamara <idankk86@gmail.com>
parents:
14770
diff
changeset
|
311 |
check(cwd) |
14882
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
312 |
|
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
313 |
hgrc = open('.hg/hgrc', 'a') |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
314 |
hgrc.write('[ui]\nfoo=bar\n') |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
315 |
hgrc.close() |
bb2cffe81a94
cmdserver: take repo.baseui as our ui
Idan Kamara <idankk86@gmail.com>
parents:
14880
diff
changeset
|
316 |
check(localhgrc) |
14889
a59058fd074a
hooks: redirect stdout/err/in to the ui descriptors when calling python hooks
Idan Kamara <idankk86@gmail.com>
parents:
14882
diff
changeset
|
317 |
check(hookoutput) |
14939
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
318 |
check(outsidechanges) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
319 |
check(bookmarks) |
b4c06b97dfe0
cmdserver: repo.invalidate() on every runcommand
Idan Kamara <idankk86@gmail.com>
parents:
14889
diff
changeset
|
320 |
check(tagscache) |
15989
6548a2e32285
test-commandserver: test that phase data is being refreshed
Idan Kamara <idankk86@gmail.com>
parents:
15542
diff
changeset
|
321 |
check(setphase) |
16116
ce0ad184f489
localrepo: clear _filecache on rollback (issue3261)
Idan Kamara <idankk86@gmail.com>
parents:
16115
diff
changeset
|
322 |
check(rollback) |
16201
fb7c4c14223f
dirstate: filecacheify _branch
Idan Kamara <idankk86@gmail.com>
parents:
16117
diff
changeset
|
323 |
check(branch) |
16202
53e2cd303ecf
dirstate: filecacheify _ignore (issue3278)
Idan Kamara <idankk86@gmail.com>
parents:
16201
diff
changeset
|
324 |
check(hgignore) |
18757
1c8e0d6ac3b0
localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
Idan Kamara <idankk86@gmail.com>
parents:
16687
diff
changeset
|
325 |
check(phasecacheafterstrip) |
20330
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
326 |
obs = open('obs.py', 'w') |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
327 |
obs.write('import mercurial.obsolete\nmercurial.obsolete._enabled = True\n') |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
328 |
obs.close() |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
329 |
hgrc = open('.hg/hgrc', 'a') |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
330 |
hgrc.write('[extensions]\nobs=obs.py\n') |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
331 |
hgrc.close() |
69a0d22b9677
dispatch: take --hidden from individual commands into account
Julien Cristau <julien.cristau@logilab.fr>
parents:
19167
diff
changeset
|
332 |
check(obsolete) |
20628
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
333 |
hgrc = open('.hg/hgrc', 'a') |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
334 |
hgrc.write('[extensions]\nmq=\n') |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
335 |
hgrc.close() |
e3d1df48fcc6
cmdserver: reload mq on each runcommand request to avoid corruption
Yuya Nishihara <yuya@tcha.org>
parents:
20396
diff
changeset
|
336 |
check(mqoutsidechanges) |
20650
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
337 |
|
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
338 |
os.chdir('..') |
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
339 |
check(hellomessage) |
e811b93f2cb1
cmdserver: allow to start server without repository
Yuya Nishihara <yuya@tcha.org>
parents:
20649
diff
changeset
|
340 |
check(startwithoutrepo) |