annotate tests/test-update.py @ 51:c52383a550fb

client: add summary command
author Idan Kamara <idankk86@gmail.com>
date Thu, 18 Aug 2011 16:23:43 +0300
parents f6e1d9a6e0cd
children a0328b08e028
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import common
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2 from hglib import error
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 class test_update(common.basetest):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 def setUp(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 common.basetest.setUp(self)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 self.append('a', 'a')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 self.rev0, self.node0 = self.client.commit('first', addremove=True)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 self.append('a', 'a')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.rev1, self.node1 = self.client.commit('second')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 def test_basic(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 u, m, r, ur = self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.assertEquals(u, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 self.assertEquals(m, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 self.assertEquals(r, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self.assertEquals(ur, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 def test_unresolved(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 u, m, r, ur = self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 self.assertEquals(u, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 self.assertEquals(m, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 self.assertEquals(r, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 self.assertEquals(ur, 1)
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
27 self.assertTrue(('M', 'a') in self.client.status())
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 def test_merge(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 self.append('a', '\n\n\n\nb')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31 rev2, node2 = self.client.commit('third')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33 self.client.commit('fourth')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34 self.client.update(rev2)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
35 old = open('a').read()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
36 open('a', 'w').write('a' + old)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
37 u, m, r, ur = self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
38 self.assertEquals(u, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
39 self.assertEquals(m, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40 self.assertEquals(r, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
41 self.assertEquals(ur, 0)
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
42 self.assertEquals(self.client.status(), [('M', 'a')])
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
43
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
44 def test_tip(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
46 u, m, r, ur = self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
47 self.assertEquals(u, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
48 self.assertEquals(self.client.parents()[0].node, self.node1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
49
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
50 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
52 rev2, node2 = self.client.commit('new head')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
53 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
54
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
55 self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
56 self.assertEquals(self.client.parents()[0].node, node2)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
57
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
58 def test_check_clean(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59 self.assertRaises(ValueError, self.client.update, clean=True, check=True)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
60
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
61 def test_clean(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
62 old = open('a').read()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
63 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
64 self.assertRaises(error.CommandError, self.client.update, check=True)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
65
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
66 u, m, r, ur = self.client.update(clean=True)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
67 self.assertEquals(u, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
68 self.assertEquals(old, open('a').read())