Mercurial > public > mercurial-scm > python-hglib
annotate tests/test-merge.py @ 179:c4c0efb37187
protocol: add the abilty to trace the protocol between the client and server
This is useful when debugging issues with driving hg via hglib
where output and error messages can be lost.
Call setprotocoltrace with the name of a trace function or None.
If the trace function is None no tracing is done.
The trace function is called with the direction, the channel-identified
and its data.
author | Barry A. Scott <barry@barrys-emacs.org> |
---|---|
date | Tue, 18 Oct 2016 17:45:17 +0100 |
parents | 8c4d24b58c23 |
children |
rev | line source |
---|---|
148
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
1 from tests import common |
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
2 import hglib |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
3 from hglib.util import b |
45 | 4 |
5 class test_merge(common.basetest): | |
6 def setUp(self): | |
7 common.basetest.setUp(self) | |
8 | |
9 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
10 rev, self.node0 = self.client.commit(b('first'), addremove=True) |
45 | 11 |
12 self.append('a', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
13 rev, self.node1 = self.client.commit(b('change')) |
45 | 14 |
15 def test_basic(self): | |
16 self.client.update(self.node0) | |
17 self.append('b', 'a') | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
18 rev, node2 = self.client.commit(b('new file'), addremove=True) |
45 | 19 self.client.merge(self.node1) |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
20 rev, node = self.client.commit(b('merge')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
21 diff = b("diff -r ") + node2[:12] + b(" -r ") + node[:12] + b(""" a |
45 | 22 --- a/a |
23 +++ b/a | |
24 @@ -1,1 +1,1 @@ | |
25 -a | |
26 \ No newline at end of file | |
27 +aa | |
28 \ No newline at end of file | |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
29 """) |
45 | 30 |
31 self.assertEquals(diff, self.client.diff(change=node, nodates=True)) | |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
32 |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
33 def test_merge_prompt_abort(self): |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
34 self.client.update(self.node0) |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
35 self.client.remove(b('a')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
36 self.client.commit(b('remove')) |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
37 |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
38 self.assertRaises(hglib.error.CommandError, self.client.merge) |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
39 |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
40 def test_merge_prompt_noninteractive(self): |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
41 self.client.update(self.node0) |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
42 self.client.remove(b('a')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
43 rev, node = self.client.commit(b('remove')) |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
44 |
173
8c4d24b58c23
tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
45 if self.client.version >= (3, 7): |
8c4d24b58c23
tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
46 self.assertRaises(hglib.error.CommandError, |
8c4d24b58c23
tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
47 self.client.merge, |
8c4d24b58c23
tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
48 cb=hglib.merge.handlers.noninteractive) |
8c4d24b58c23
tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
49 else: |
8c4d24b58c23
tests: adjust test-merge for mercurial 3.7
Julien Cristau <julien.cristau@logilab.fr>
parents:
148
diff
changeset
|
50 self.client.merge(cb=hglib.merge.handlers.noninteractive) |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
51 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
52 diff = b("diff -r ") + node[:12] + b(""" a |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
53 --- /dev/null |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
54 +++ b/a |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
55 @@ -0,0 +1,1 @@ |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
56 +aa |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
57 \ No newline at end of file |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
58 """) |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
59 self.assertEquals(diff, self.client.diff(nodates=True)) |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
60 |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
61 def test_merge_prompt_cb(self): |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
62 self.client.update(self.node0) |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
63 self.client.remove(b('a')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
64 rev, node = self.client.commit(b('remove')) |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
65 |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
66 def cb(output): |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
67 return b('c') |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
68 |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
69 self.client.merge(cb=cb) |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
70 |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
71 diff = b("diff -r ") + node[:12] + b(""" a |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
72 --- /dev/null |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
73 +++ b/a |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
74 @@ -0,0 +1,1 @@ |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
75 +aa |
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
76 \ No newline at end of file |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
46
diff
changeset
|
77 """) |
46
ebcc5d7dd528
client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents:
45
diff
changeset
|
78 self.assertEquals(diff, self.client.diff(nodates=True)) |