annotate tests/test-merge.py @ 123:cdde1656346f

client: add 'hidden' property to show hidden changesets. This enables interactions with the obsolete changesets in the repository: - add the attribute in client class - add the keyword to the relevant commands - enable log without hidden changesets even when self.hidden is True - add a few tests with the hidden keyword This changeset mirrors the behavior of the mercurial global command --hidden: an attribute is added to the client library. If set at True, adds the hidden keyword to all command which can use it to show hidden changesets. The alternative would be to add the keyword in rawcommand, but the hidden flag is not relevant for commands such as add or branch.
author Paul Tonelli <paul.tonelli@logilab.fr>
date Thu, 22 May 2014 15:23:12 +0200
parents ebcc5d7dd528
children 4359cabcb0cc
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
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3 class test_merge(common.basetest):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 def setUp(self):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 common.basetest.setUp(self)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 self.append('a', 'a')
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 rev, self.node0 = self.client.commit('first', addremove=True)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.append('a', 'a')
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 rev, self.node1 = self.client.commit('change')
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 def test_basic(self):
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.client.update(self.node0)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 self.append('b', 'a')
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 rev, node2 = self.client.commit('new file', addremove=True)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self.client.merge(self.node1)
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 rev, node = self.client.commit('merge')
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 diff = """diff -r %s -r %s a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 --- a/a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 +++ b/a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 @@ -1,1 +1,1 @@
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 -a
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 \ No newline at end of file
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 +aa
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 \ No newline at end of file
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 """ % (node2[:12], node[:12])
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28
191855a9d813 client: add merge command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 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
30
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
31 def test_merge_prompt_abort(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
32 self.client.update(self.node0)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
33 self.client.remove('a')
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
34 self.client.commit('remove')
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
35
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
36 self.assertRaises(hglib.error.CommandError, self.client.merge)
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 def test_merge_prompt_noninteractive(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
39 self.client.update(self.node0)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
40 self.client.remove('a')
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
41 rev, node = self.client.commit('remove')
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
42
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
43 self.client.merge(cb=hglib.merge.handlers.noninteractive)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
44
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
45 diff = """diff -r %s a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
46 --- /dev/null
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
47 +++ b/a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
48 @@ -0,0 +1,1 @@
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
49 +aa
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
50 \ No newline at end of file
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
51 """ % node[:12]
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
52 self.assertEquals(diff, self.client.diff(nodates=True))
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
53
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
54 def test_merge_prompt_cb(self):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
55 self.client.update(self.node0)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
56 self.client.remove('a')
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
57 rev, node = self.client.commit('remove')
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
58
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
59 def cb(output):
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
60 return 'c'
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
61
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
62 self.client.merge(cb=cb)
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
63
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
64 diff = """diff -r %s a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
65 --- /dev/null
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
66 +++ b/a
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
67 @@ -0,0 +1,1 @@
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
68 +aa
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
69 \ No newline at end of file
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
70 """ % node[:12]
ebcc5d7dd528 client: introduce merge handlers
Idan Kamara <idankk86@gmail.com>
parents: 45
diff changeset
71 self.assertEquals(diff, self.client.diff(nodates=True))