Mercurial > python-hglib
comparison tests/test_update.py @ 219:8341f2494b3f
hglib tests: migrate away from (unmaintained) nose
author | Mathias De Mare <mathias.de_mare@nokia.com> |
---|---|
date | Wed, 08 Mar 2023 17:04:58 +0100 |
parents | tests/test-update.py@b91356bf7186 |
children | a2afbf236ca8 |
comparison
equal
deleted
inserted
replaced
218:934608d4fcba | 219:8341f2494b3f |
---|---|
1 from tests import common | |
2 from hglib import error | |
3 from hglib.util import b, strtobytes | |
4 | |
5 class test_update(common.basetest): | |
6 def setUp(self): | |
7 common.basetest.setUp(self) | |
8 self.append('a', 'a') | |
9 self.rev0, self.node0 = self.client.commit(b('first'), addremove=True) | |
10 self.append('a', 'a') | |
11 self.rev1, self.node1 = self.client.commit(b('second')) | |
12 | |
13 def test_basic(self): | |
14 u, m, r, ur = self.client.update(self.rev0) | |
15 self.assertEquals(u, 1) | |
16 self.assertEquals(m, 0) | |
17 self.assertEquals(r, 0) | |
18 self.assertEquals(ur, 0) | |
19 | |
20 def test_unresolved(self): | |
21 self.client.update(self.rev0) | |
22 self.append('a', 'b') | |
23 u, m, r, ur = self.client.update() | |
24 self.assertEquals(u, 0) | |
25 self.assertEquals(m, 0) | |
26 self.assertEquals(r, 0) | |
27 self.assertEquals(ur, 1) | |
28 self.assertTrue((b('M'), b('a')) in self.client.status()) | |
29 | |
30 def test_merge(self): | |
31 self.append('a', '\n\n\n\nb') | |
32 rev2, node2 = self.client.commit(b('third')) | |
33 self.append('a', 'b') | |
34 self.client.commit(b('fourth')) | |
35 self.client.update(rev2) | |
36 old = open('a').read() | |
37 f = open('a', 'wb') | |
38 f.write(b('a') + old.encode('latin-1')) | |
39 f.close() | |
40 u, m, r, ur = self.client.update() | |
41 self.assertEquals(u, 0) | |
42 self.assertEquals(m, 1) | |
43 self.assertEquals(r, 0) | |
44 self.assertEquals(ur, 0) | |
45 self.assertEquals(self.client.status(), [(b('M'), b('a'))]) | |
46 | |
47 def test_tip(self): | |
48 self.client.update(self.rev0) | |
49 u, m, r, ur = self.client.update() | |
50 self.assertEquals(u, 1) | |
51 self.assertEquals(self.client.parents()[0].node, self.node1) | |
52 | |
53 self.client.update(self.rev0) | |
54 self.append('a', 'b') | |
55 rev2, node2 = self.client.commit(b('new head')) | |
56 self.client.update(self.rev0) | |
57 | |
58 self.client.update() | |
59 self.assertEquals(self.client.parents()[0].node, node2) | |
60 | |
61 def test_check_clean(self): | |
62 self.assertRaises(ValueError, self.client.update, clean=True, | |
63 check=True) | |
64 | |
65 def test_clean(self): | |
66 old = open('a').read() | |
67 self.append('a', 'b') | |
68 self.assertRaises(error.CommandError, self.client.update, check=True) | |
69 | |
70 u, m, r, ur = self.client.update(clean=True) | |
71 self.assertEquals(u, 1) | |
72 self.assertEquals(old, open('a').read()) | |
73 | |
74 def test_basic_plain(self): | |
75 f = open('.hg/hgrc', 'a') | |
76 f.write('[defaults]\nupdate=-v\n') | |
77 f.close() | |
78 self.test_basic() | |
79 | |
80 def disabled_largefiles(self): | |
81 # we don't run reposetup after a session has started, so this | |
82 # test is broken | |
83 import os | |
84 f = open('.hg/hgrc', 'a') | |
85 f.write('[extensions]\nlargefiles=\n') | |
86 f.close() | |
87 self.append('b', 'a') | |
88 try: | |
89 self.client.rawcommand([b('add'), b('b'), b('--large')]) | |
90 except error.CommandError: | |
91 return | |
92 | |
93 rev2, node2 = self.client.commit(b('third')) | |
94 # Go back to 0 | |
95 self.client.rawcommand([b('update'), strtobytes(self.rev0)], | |
96 # Keep the 'changed' version | |
97 prompt=lambda s, d: 'c\n') | |
98 u, m, r, ur = self.client.update(rev2, clean=True) | |
99 self.assertEquals(u, 2) | |
100 self.assertEquals(m, 0) | |
101 self.assertEquals(r, 0) | |
102 self.assertEquals(ur, 0) |