annotate tests/test-sshserver.py @ 36927:17a744c5e270

rebase: also include commit of collapsed commits in single transaction When rebase.singletransaction is set, we still used to create a second transaction when committing with --collapse. It's simpler to create a single transaction. Note that in the affected .t file, the test that uses --collapse still appears to create two transactions (it prints "rebase status stored" twice). However, only a single transaction is actually created and the second printout comes from cmdutil.commitforceeditor() that explicitly calls tr.writepending(). Also note the that we now roll back any commits if the user closes the commit message editor with an error code (or leaves the message empty). That might be unfortunate, but it's consistent with how we behave in the --no-collapse case (if the user passed --edit). If we want to change that, I think it should be done consistently in a separate patch. Differential Revision: https://phab.mercurial-scm.org/D2728
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 09 Mar 2018 10:35:48 -0800
parents 3b3a987bbbaa
children a8a902d7176e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
1 from __future__ import absolute_import, print_function
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
2
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
3 import io
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
4 import unittest
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
5
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
6 import silenttestrunner
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
7
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
8 from mercurial import (
35772
7764ff13318e test-sshserver: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35752
diff changeset
9 util,
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
10 wireproto,
35859
1bf5263fe5cc wireprotoserver: move sshserver into module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35772
diff changeset
11 wireprotoserver,
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
12 )
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
13
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
14 class SSHServerGetArgsTests(unittest.TestCase):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
15 def testparseknown(self):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
16 tests = [
36212
7a46f0735904 py3: add b'' to test-sshserver.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36065
diff changeset
17 (b'* 0\nnodes 0\n', [b'', {}]),
7a46f0735904 py3: add b'' to test-sshserver.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36065
diff changeset
18 (b'* 0\nnodes 40\n1111111111111111111111111111111111111111\n',
7a46f0735904 py3: add b'' to test-sshserver.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36065
diff changeset
19 [b'1111111111111111111111111111111111111111', {}]),
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
20 ]
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
21 for input, expected in tests:
36212
7a46f0735904 py3: add b'' to test-sshserver.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36065
diff changeset
22 self.assertparse(b'known', input, expected)
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
23
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
24 def assertparse(self, cmd, input, expected):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
25 server = mockserver(input)
36214
3b3a987bbbaa wireprotoserver: move SSH server operation to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36212
diff changeset
26 proto = wireprotoserver.sshv1protocolhandler(server._ui,
3b3a987bbbaa wireprotoserver: move SSH server operation to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36212
diff changeset
27 server._fin,
3b3a987bbbaa wireprotoserver: move SSH server operation to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36212
diff changeset
28 server._fout)
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
29 _func, spec = wireproto.commands[cmd]
36214
3b3a987bbbaa wireprotoserver: move SSH server operation to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36212
diff changeset
30 self.assertEqual(proto.getargs(spec), expected)
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
31
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
32 def mockserver(inbytes):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
33 ui = mockui(inbytes)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
34 repo = mockrepo(ui)
35859
1bf5263fe5cc wireprotoserver: move sshserver into module (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35772
diff changeset
35 return wireprotoserver.sshserver(ui, repo)
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
36
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
37 class mockrepo(object):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
38 def __init__(self, ui):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
39 self.ui = ui
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
40
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
41 class mockui(object):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
42 def __init__(self, inbytes):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
43 self.fin = io.BytesIO(inbytes)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
44 self.fout = io.BytesIO()
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
45 self.ferr = io.BytesIO()
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
46
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
47 if __name__ == '__main__':
35772
7764ff13318e test-sshserver: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35752
diff changeset
48 # Don't call into msvcrt to set BytesIO to binary mode
7764ff13318e test-sshserver: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35752
diff changeset
49 util.setbinary = lambda fp: True
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
50 silenttestrunner.main(__name__)