Mercurial > python-hglib
annotate tests/test-merge.py @ 121:cc905ee18449
Added tag 1.2 for changeset 5d3783aebe5f
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 01 Feb 2014 15:30:18 -0600 |
parents | ebcc5d7dd528 |
children | 4359cabcb0cc |
rev | line source |
---|---|
45 | 1 import common, hglib |
2 | |
3 class test_merge(common.basetest): | |
4 def setUp(self): | |
5 common.basetest.setUp(self) | |
6 | |
7 self.append('a', 'a') | |
8 rev, self.node0 = self.client.commit('first', addremove=True) | |
9 | |
10 self.append('a', 'a') | |
11 rev, self.node1 = self.client.commit('change') | |
12 | |
13 def test_basic(self): | |
14 self.client.update(self.node0) | |
15 self.append('b', 'a') | |
16 rev, node2 = self.client.commit('new file', addremove=True) | |
17 self.client.merge(self.node1) | |
18 rev, node = self.client.commit('merge') | |
19 diff = """diff -r %s -r %s a | |
20 --- a/a | |
21 +++ b/a | |
22 @@ -1,1 +1,1 @@ | |
23 -a | |
24 \ No newline at end of file | |
25 +aa | |
26 \ No newline at end of file | |
27 """ % (node2[:12], node[:12]) | |
28 | |
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)) |