20
|
1 import common
|
|
2 from hglib import error
|
|
3
|
|
4 class test_update(common.basetest):
|
|
5 def setUp(self):
|
|
6 common.basetest.setUp(self)
|
|
7 self.append('a', 'a')
|
|
8 self.rev0, self.node0 = self.client.commit('first', addremove=True)
|
|
9 self.append('a', 'a')
|
|
10 self.rev1, self.node1 = self.client.commit('second')
|
|
11
|
|
12 def test_basic(self):
|
|
13 u, m, r, ur = self.client.update(self.rev0)
|
|
14 self.assertEquals(u, 1)
|
|
15 self.assertEquals(m, 0)
|
|
16 self.assertEquals(r, 0)
|
|
17 self.assertEquals(ur, 0)
|
|
18
|
|
19 def test_unresolved(self):
|
|
20 self.client.update(self.rev0)
|
|
21 self.append('a', 'b')
|
|
22 u, m, r, ur = self.client.update()
|
|
23 self.assertEquals(u, 0)
|
|
24 self.assertEquals(m, 0)
|
|
25 self.assertEquals(r, 0)
|
|
26 self.assertEquals(ur, 1)
|
|
27 self.assertEquals(self.client.status()['M'][0], 'a')
|
|
28
|
|
29 def test_merge(self):
|
|
30 self.append('a', '\n\n\n\nb')
|
|
31 rev2, node2 = self.client.commit('third')
|
|
32 self.append('a', 'b')
|
|
33 self.client.commit('fourth')
|
|
34 self.client.update(rev2)
|
|
35 old = open('a').read()
|
|
36 open('a', 'w').write('a' + old)
|
|
37 u, m, r, ur = self.client.update()
|
|
38 self.assertEquals(u, 0)
|
|
39 self.assertEquals(m, 1)
|
|
40 self.assertEquals(r, 0)
|
|
41 self.assertEquals(ur, 0)
|
|
42 self.assertEquals(self.client.status()['M'][0], 'a')
|
|
43
|
|
44 def test_tip(self):
|
|
45 self.client.update(self.rev0)
|
|
46 u, m, r, ur = self.client.update()
|
|
47 self.assertEquals(u, 1)
|
|
48 self.assertEquals(self.client.parents()[0].node, self.node1)
|
|
49
|
|
50 self.client.update(self.rev0)
|
|
51 self.append('a', 'b')
|
|
52 rev2, node2 = self.client.commit('new head')
|
|
53 self.client.update(self.rev0)
|
|
54
|
|
55 self.client.update()
|
|
56 self.assertEquals(self.client.parents()[0].node, node2)
|
|
57
|
|
58 def test_check_clean(self):
|
|
59 self.assertRaises(ValueError, self.client.update, clean=True, check=True)
|
|
60
|
|
61 def test_clean(self):
|
|
62 old = open('a').read()
|
|
63 self.append('a', 'b')
|
|
64 self.assertRaises(error.CommandError, self.client.update, check=True)
|
|
65
|
|
66 u, m, r, ur = self.client.update(clean=True)
|
|
67 self.assertEquals(u, 1)
|
|
68 self.assertEquals(old, open('a').read())
|