annotate tests/test-merge.py @ 145:f3c430afa598

hglib: abstract out use of cStringIO.StringIO (issue4520) The cStringIO module does not exist in Python 3, but io.BytesIO does. This change prepares for the use of io.BytesIO when available by replacing all uses of cStringIO.StringIO with an object named BytesIO.
author Brett Cannon <brett@python.org>
date Fri, 13 Mar 2015 11:31:54 -0400
parents 4359cabcb0cc
children c1b966866ed7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import common, hglib
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
2 from hglib.util import b
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 class test_merge(common.basetest):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 def setUp(self):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 common.basetest.setUp(self)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 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
9 rev, self.node0 = self.client.commit(b('first'), addremove=True)
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 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
12 rev, self.node1 = self.client.commit(b('change'))
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 def test_basic(self):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 self.client.update(self.node0)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 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
17 rev, node2 = self.client.commit(b('new file'), addremove=True)
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 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
19 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
20 diff = b("diff -r ") + node2[:12] + b(" -r ") + node[:12] + b(""" a
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 --- a/a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 +++ b/a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 @@ -1,1 +1,1 @@
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 -a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 \ No newline at end of file
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 +aa
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 \ 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
28 """)
45
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 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
31
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
32 def test_merge_prompt_abort(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
33 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
34 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
35 self.client.commit(b('remove'))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
36
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
37 self.assertRaises(hglib.error.CommandError, self.client.merge)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
38
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
39 def test_merge_prompt_noninteractive(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
40 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
41 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
42 rev, node = self.client.commit(b('remove'))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
43
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
44 self.client.merge(cb=hglib.merge.handlers.noninteractive)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
45
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
46 diff = b("diff -r ") + node[:12] + b(""" a
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
47 --- /dev/null
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
48 +++ b/a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
49 @@ -0,0 +1,1 @@
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
50 +aa
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
51 \ 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
52 """)
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
53 self.assertEquals(diff, self.client.diff(nodates=True))
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
54
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
55 def test_merge_prompt_cb(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
56 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
57 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
58 rev, node = self.client.commit(b('remove'))
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
59
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
60 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
61 return b('c')
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
62
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
63 self.client.merge(cb=cb)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
64
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 46
diff changeset
65 diff = b("diff -r ") + node[:12] + b(""" a
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
66 --- /dev/null
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
67 +++ b/a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
68 @@ -0,0 +1,1 @@
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
69 +aa
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
70 \ 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
71 """)
46
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
72 self.assertEquals(diff, self.client.diff(nodates=True))