Mercurial > public > mercurial-scm > python-hglib
annotate tests/test-summary.py @ 188:5609a21fe39a
client: fail gracefully on unexpected prompts (issue5516)
Right now, if hglib encounters an unexpected prompt, it fails with a rather
opaque "unexpected data on required channel 'L'" error message. Furthermore,
if subsequently another command is called on the same client instance, both
the client and server processes lock up hard (at least on Windows), and the
server process rapidly leaks ~2GB of memory.
Fix this by responding with an empty string to any unexpected prompt. This
will trigger an "abort: response expected" exception from the server, which
is easily handled as a CommandError, and subsequent commands sent from the
same client work as expected.
This doesn't completely resolve bug 5516, as unexpected requests on another
required channel (e.g. I) can still cause a lockup.
However, it does fix the most common case of an unexpected password prompt.
author | G?bor Stefanik <gabor.stefanik@nng.com> |
---|---|
date | Tue, 12 Sep 2017 13:16:36 -0400 |
parents | 9062a6b935ad |
children |
rev | line source |
---|---|
187
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
1 import unittest |
148
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
2 from tests import common |
51 | 3 import hglib |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
4 from hglib.util import b |
51 | 5 |
6 class test_summary(common.basetest): | |
7 def test_empty(self): | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
8 d = {b('parent') : [(-1, b('000000000000'), b('tip'), None)], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
9 b('branch') : b('default'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
10 b('commit') : True, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
11 b('update') : 0} |
51 | 12 |
13 self.assertEquals(self.client.summary(), d) | |
14 | |
15 def test_basic(self): | |
16 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
17 rev, node = self.client.commit(b('first'), addremove=True) |
51 | 18 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
19 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
20 b('branch') : b('default'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
21 b('commit') : True, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
22 b('update') : 0} |
164
568bca4ff58e
tests: update test-summary for mercurial 3.5
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
23 if self.client.version >= (3, 5): |
165
dbb21a4c0eb9
tests: fix test-summary for python3
Julien Cristau <julien.cristau@logilab.fr>
parents:
164
diff
changeset
|
24 d[b('phases')] = b('1 draft') |
51 | 25 |
26 self.assertEquals(self.client.summary(), d) | |
27 | |
28 def test_commit_dirty(self): | |
29 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
30 rev, node = self.client.commit(b('first'), addremove=True) |
51 | 31 self.append('a', 'a') |
32 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
33 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
34 b('branch') : b('default'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
35 b('commit') : False, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
36 b('update') : 0} |
164
568bca4ff58e
tests: update test-summary for mercurial 3.5
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
37 if self.client.version >= (3, 5): |
165
dbb21a4c0eb9
tests: fix test-summary for python3
Julien Cristau <julien.cristau@logilab.fr>
parents:
164
diff
changeset
|
38 d[b('phases')] = b('1 draft') |
51 | 39 |
40 self.assertEquals(self.client.summary(), d) | |
41 | |
187
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
42 def test_secret_commit_clean(self): |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
43 if self.client.version < (2, 1): |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
44 raise unittest.SkipTest('phase not supported') |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
45 self.append('a', 'a') |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
46 rev, node = self.client.commit(b('first'), addremove=True) |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
47 self.client.phase([b('%d') % rev], secret=True, force=True) |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
48 e = self.client.summary() |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
49 self.assertTrue(e[b('commit')]) |
9062a6b935ad
summary: parse commit line less strictly (issue5637)
Yuya Nishihara <yuya@tcha.org>
parents:
165
diff
changeset
|
50 |
51 | 51 def test_update(self): |
52 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
53 rev, node = self.client.commit(b('first'), addremove=True) |
51 | 54 self.append('a', 'a') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
55 self.client.commit(b('second')) |
51 | 56 self.client.update(0) |
57 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
58 d = {b('parent') : [(0, node[:12], None, b('first'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
59 b('branch') : b('default'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
60 b('commit') : True, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
61 b('update') : 1} |
164
568bca4ff58e
tests: update test-summary for mercurial 3.5
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
62 if self.client.version >= (3, 5): |
165
dbb21a4c0eb9
tests: fix test-summary for python3
Julien Cristau <julien.cristau@logilab.fr>
parents:
164
diff
changeset
|
63 d[b('phases')] = b('2 draft') |
51 | 64 |
65 self.assertEquals(self.client.summary(), d) | |
66 | |
67 def test_remote(self): | |
68 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
69 rev, node = self.client.commit(b('first'), addremove=True) |
51 | 70 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
71 self.client.clone(dest=b('other')) |
51 | 72 other = hglib.open('other') |
73 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
74 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
75 b('branch') : b('default'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
76 b('commit') : True, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
77 b('update') : 0, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
78 b('remote') : (0, 0, 0, 0)} |
51 | 79 |
80 self.assertEquals(other.summary(remote=True), d) | |
81 | |
82 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
83 self.client.commit(b('second')) |
51 | 84 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
85 d[b('remote')] = (1, 0, 0, 0) |
51 | 86 self.assertEquals(other.summary(remote=True), d) |
87 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
88 self.client.bookmark(b('bm')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
89 d[b('remote')] = (1, 1, 0, 0) |
51 | 90 self.assertEquals(other.summary(remote=True), d) |
91 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
92 other.bookmark(b('bmother')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
93 d[b('remote')] = (1, 1, 0, 1) |
88
3bbf6a3266f4
test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
94 if self.client.version < (2, 0, 0): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
95 d[b('parent')] = [(0, node[:12], b('tip bmother'), b('first'))] |
88
3bbf6a3266f4
test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
96 else: |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
97 d[b('bookmarks')] = b('*bmother') |
51 | 98 self.assertEquals(other.summary(remote=True), d) |
99 | |
100 self.append('other/a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
101 rev, node = other.commit(b('second in other')) |
51 | 102 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
103 d[b('remote')] = (1, 1, 1, 1) |
88
3bbf6a3266f4
test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
104 if self.client.version < (2, 0, 0): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
105 tags = b('tip bmother') |
88
3bbf6a3266f4
test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents:
51
diff
changeset
|
106 else: |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
107 tags = b('tip') |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
108 d[b('parent')] = [(1, node[:12], tags, b('second in other'))] |
164
568bca4ff58e
tests: update test-summary for mercurial 3.5
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
109 if self.client.version >= (3, 5): |
165
dbb21a4c0eb9
tests: fix test-summary for python3
Julien Cristau <julien.cristau@logilab.fr>
parents:
164
diff
changeset
|
110 d[b('phases')] = b('1 draft') |
51 | 111 |
112 self.assertEquals(other.summary(remote=True), d) | |
113 | |
114 def test_two_parents(self): | |
115 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
116 rev0, node = self.client.commit(b('first'), addremove=True) |
51 | 117 |
118 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
119 rev1, node1 = self.client.commit(b('second')) |
51 | 120 |
121 self.client.update(rev0) | |
122 self.append('b', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
123 rev2, node2 = self.client.commit(b('third'), addremove=True) |
51 | 124 |
125 self.client.merge(rev1) | |
126 | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
127 d = {b('parent') : [(2, node2[:12], b('tip'), b('third')), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
128 (1, node1[:12], None, b('second'))], |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
129 b('branch') : b('default'), |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
130 b('commit') : False, |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
88
diff
changeset
|
131 b('update') : 0} |
164
568bca4ff58e
tests: update test-summary for mercurial 3.5
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
132 if self.client.version >= (3, 5): |
165
dbb21a4c0eb9
tests: fix test-summary for python3
Julien Cristau <julien.cristau@logilab.fr>
parents:
164
diff
changeset
|
133 d[b('phases')] = b('3 draft') |
51 | 134 |
135 self.assertEquals(self.client.summary(), d) |