Mercurial > python-hglib
comparison tests/test-update.py @ 143:4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
author | Brett Cannon <brett@python.org> |
---|---|
date | Mon, 09 Mar 2015 18:26:25 -0400 |
parents | 9c4f52467208 |
children | c1b966866ed7 |
comparison
equal
deleted
inserted
replaced
142:fe74d5599539 | 143:4359cabcb0cc |
---|---|
1 import common | 1 import common |
2 from hglib import error | 2 from hglib import error |
3 from hglib.util import b | |
3 | 4 |
4 class test_update(common.basetest): | 5 class test_update(common.basetest): |
5 def setUp(self): | 6 def setUp(self): |
6 common.basetest.setUp(self) | 7 common.basetest.setUp(self) |
7 self.append('a', 'a') | 8 self.append('a', 'a') |
8 self.rev0, self.node0 = self.client.commit('first', addremove=True) | 9 self.rev0, self.node0 = self.client.commit(b('first'), addremove=True) |
9 self.append('a', 'a') | 10 self.append('a', 'a') |
10 self.rev1, self.node1 = self.client.commit('second') | 11 self.rev1, self.node1 = self.client.commit(b('second')) |
11 | 12 |
12 def test_basic(self): | 13 def test_basic(self): |
13 u, m, r, ur = self.client.update(self.rev0) | 14 u, m, r, ur = self.client.update(self.rev0) |
14 self.assertEquals(u, 1) | 15 self.assertEquals(u, 1) |
15 self.assertEquals(m, 0) | 16 self.assertEquals(m, 0) |
22 u, m, r, ur = self.client.update() | 23 u, m, r, ur = self.client.update() |
23 self.assertEquals(u, 0) | 24 self.assertEquals(u, 0) |
24 self.assertEquals(m, 0) | 25 self.assertEquals(m, 0) |
25 self.assertEquals(r, 0) | 26 self.assertEquals(r, 0) |
26 self.assertEquals(ur, 1) | 27 self.assertEquals(ur, 1) |
27 self.assertTrue(('M', 'a') in self.client.status()) | 28 self.assertTrue((b('M'), b('a')) in self.client.status()) |
28 | 29 |
29 def test_merge(self): | 30 def test_merge(self): |
30 self.append('a', '\n\n\n\nb') | 31 self.append('a', '\n\n\n\nb') |
31 rev2, node2 = self.client.commit('third') | 32 rev2, node2 = self.client.commit(b('third')) |
32 self.append('a', 'b') | 33 self.append('a', 'b') |
33 self.client.commit('fourth') | 34 self.client.commit(b('fourth')) |
34 self.client.update(rev2) | 35 self.client.update(rev2) |
35 old = open('a').read() | 36 old = open('a').read() |
36 f = open('a', 'wb') | 37 f = open('a', 'wb') |
37 f.write('a' + old) | 38 f.write(b('a') + old.encode('latin-1')) |
38 f.close() | 39 f.close() |
39 u, m, r, ur = self.client.update() | 40 u, m, r, ur = self.client.update() |
40 self.assertEquals(u, 0) | 41 self.assertEquals(u, 0) |
41 self.assertEquals(m, 1) | 42 self.assertEquals(m, 1) |
42 self.assertEquals(r, 0) | 43 self.assertEquals(r, 0) |
43 self.assertEquals(ur, 0) | 44 self.assertEquals(ur, 0) |
44 self.assertEquals(self.client.status(), [('M', 'a')]) | 45 self.assertEquals(self.client.status(), [(b('M'), b('a'))]) |
45 | 46 |
46 def test_tip(self): | 47 def test_tip(self): |
47 self.client.update(self.rev0) | 48 self.client.update(self.rev0) |
48 u, m, r, ur = self.client.update() | 49 u, m, r, ur = self.client.update() |
49 self.assertEquals(u, 1) | 50 self.assertEquals(u, 1) |
50 self.assertEquals(self.client.parents()[0].node, self.node1) | 51 self.assertEquals(self.client.parents()[0].node, self.node1) |
51 | 52 |
52 self.client.update(self.rev0) | 53 self.client.update(self.rev0) |
53 self.append('a', 'b') | 54 self.append('a', 'b') |
54 rev2, node2 = self.client.commit('new head') | 55 rev2, node2 = self.client.commit(b('new head')) |
55 self.client.update(self.rev0) | 56 self.client.update(self.rev0) |
56 | 57 |
57 self.client.update() | 58 self.client.update() |
58 self.assertEquals(self.client.parents()[0].node, node2) | 59 self.assertEquals(self.client.parents()[0].node, node2) |
59 | 60 |
83 f = open('.hg/hgrc', 'a') | 84 f = open('.hg/hgrc', 'a') |
84 f.write('[extensions]\nlargefiles=\n') | 85 f.write('[extensions]\nlargefiles=\n') |
85 f.close() | 86 f.close() |
86 self.append('b', 'a') | 87 self.append('b', 'a') |
87 try: | 88 try: |
88 self.client.rawcommand(['add', 'b', '--large']) | 89 self.client.rawcommand([b('add'), b('b'), b('--large')]) |
89 except error.CommandError: | 90 except error.CommandError: |
90 return | 91 return |
91 | 92 |
92 rev2, node2 = self.client.commit('third') | 93 rev2, node2 = self.client.commit(b('third')) |
93 # Go back to 0 | 94 # Go back to 0 |
94 self.client.rawcommand(['update', str(self.rev0)], | 95 self.client.rawcommand([b('update'), str(self.rev0).encode('latin-1')], |
95 # Keep the 'changed' version | 96 # Keep the 'changed' version |
96 prompt=lambda s, d: 'c\n') | 97 prompt=lambda s, d: 'c\n') |
97 u, m, r, ur = self.client.update(rev2, clean=True) | 98 u, m, r, ur = self.client.update(rev2, clean=True) |
98 self.assertEquals(u, 2) | 99 self.assertEquals(u, 2) |
99 self.assertEquals(m, 0) | 100 self.assertEquals(m, 0) |