comparison tests/test-summary.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 3bbf6a3266f4
children c1b966866ed7
comparison
equal deleted inserted replaced
142:fe74d5599539 143:4359cabcb0cc
1 import common 1 import common
2 import hglib 2 import hglib
3 from hglib.util import b
3 4
4 class test_summary(common.basetest): 5 class test_summary(common.basetest):
5 def test_empty(self): 6 def test_empty(self):
6 d = {'parent' : [(-1, '000000000000', 'tip', None)], 7 d = {b('parent') : [(-1, b('000000000000'), b('tip'), None)],
7 'branch' : 'default', 8 b('branch') : b('default'),
8 'commit' : True, 9 b('commit') : True,
9 'update' : 0} 10 b('update') : 0}
10 11
11 self.assertEquals(self.client.summary(), d) 12 self.assertEquals(self.client.summary(), d)
12 13
13 def test_basic(self): 14 def test_basic(self):
14 self.append('a', 'a') 15 self.append('a', 'a')
15 rev, node = self.client.commit('first', addremove=True) 16 rev, node = self.client.commit(b('first'), addremove=True)
16 17
17 d = {'parent' : [(0, node[:12], 'tip', 'first')], 18 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
18 'branch' : 'default', 19 b('branch') : b('default'),
19 'commit' : True, 20 b('commit') : True,
20 'update' : 0} 21 b('update') : 0}
21 22
22 self.assertEquals(self.client.summary(), d) 23 self.assertEquals(self.client.summary(), d)
23 24
24 def test_commit_dirty(self): 25 def test_commit_dirty(self):
25 self.append('a', 'a') 26 self.append('a', 'a')
26 rev, node = self.client.commit('first', addremove=True) 27 rev, node = self.client.commit(b('first'), addremove=True)
27 self.append('a', 'a') 28 self.append('a', 'a')
28 29
29 d = {'parent' : [(0, node[:12], 'tip', 'first')], 30 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
30 'branch' : 'default', 31 b('branch') : b('default'),
31 'commit' : False, 32 b('commit') : False,
32 'update' : 0} 33 b('update') : 0}
33 34
34 self.assertEquals(self.client.summary(), d) 35 self.assertEquals(self.client.summary(), d)
35 36
36 def test_update(self): 37 def test_update(self):
37 self.append('a', 'a') 38 self.append('a', 'a')
38 rev, node = self.client.commit('first', addremove=True) 39 rev, node = self.client.commit(b('first'), addremove=True)
39 self.append('a', 'a') 40 self.append('a', 'a')
40 self.client.commit('second') 41 self.client.commit(b('second'))
41 self.client.update(0) 42 self.client.update(0)
42 43
43 d = {'parent' : [(0, node[:12], None, 'first')], 44 d = {b('parent') : [(0, node[:12], None, b('first'))],
44 'branch' : 'default', 45 b('branch') : b('default'),
45 'commit' : True, 46 b('commit') : True,
46 'update' : 1} 47 b('update') : 1}
47 48
48 self.assertEquals(self.client.summary(), d) 49 self.assertEquals(self.client.summary(), d)
49 50
50 def test_remote(self): 51 def test_remote(self):
51 self.append('a', 'a') 52 self.append('a', 'a')
52 rev, node = self.client.commit('first', addremove=True) 53 rev, node = self.client.commit(b('first'), addremove=True)
53 54
54 self.client.clone(dest='other') 55 self.client.clone(dest=b('other'))
55 other = hglib.open('other') 56 other = hglib.open('other')
56 57
57 d = {'parent' : [(0, node[:12], 'tip', 'first')], 58 d = {b('parent') : [(0, node[:12], b('tip'), b('first'))],
58 'branch' : 'default', 59 b('branch') : b('default'),
59 'commit' : True, 60 b('commit') : True,
60 'update' : 0, 61 b('update') : 0,
61 'remote' : (0, 0, 0, 0)} 62 b('remote') : (0, 0, 0, 0)}
62 63
63 self.assertEquals(other.summary(remote=True), d) 64 self.assertEquals(other.summary(remote=True), d)
64 65
65 self.append('a', 'a') 66 self.append('a', 'a')
66 self.client.commit('second') 67 self.client.commit(b('second'))
67 68
68 d['remote'] = (1, 0, 0, 0) 69 d[b('remote')] = (1, 0, 0, 0)
69 self.assertEquals(other.summary(remote=True), d) 70 self.assertEquals(other.summary(remote=True), d)
70 71
71 self.client.bookmark('bm') 72 self.client.bookmark(b('bm'))
72 d['remote'] = (1, 1, 0, 0) 73 d[b('remote')] = (1, 1, 0, 0)
73 self.assertEquals(other.summary(remote=True), d) 74 self.assertEquals(other.summary(remote=True), d)
74 75
75 other.bookmark('bmother') 76 other.bookmark(b('bmother'))
76 d['remote'] = (1, 1, 0, 1) 77 d[b('remote')] = (1, 1, 0, 1)
77 if self.client.version < (2, 0, 0): 78 if self.client.version < (2, 0, 0):
78 d['parent'] = [(0, node[:12], 'tip bmother', 'first')] 79 d[b('parent')] = [(0, node[:12], b('tip bmother'), b('first'))]
79 else: 80 else:
80 d['bookmarks'] = '*bmother' 81 d[b('bookmarks')] = b('*bmother')
81 self.assertEquals(other.summary(remote=True), d) 82 self.assertEquals(other.summary(remote=True), d)
82 83
83 self.append('other/a', 'a') 84 self.append('other/a', 'a')
84 rev, node = other.commit('second in other') 85 rev, node = other.commit(b('second in other'))
85 86
86 d['remote'] = (1, 1, 1, 1) 87 d[b('remote')] = (1, 1, 1, 1)
87 if self.client.version < (2, 0, 0): 88 if self.client.version < (2, 0, 0):
88 tags = 'tip bmother' 89 tags = b('tip bmother')
89 else: 90 else:
90 tags = 'tip' 91 tags = b('tip')
91 d['parent'] = [(1, node[:12], tags, 'second in other')] 92 d[b('parent')] = [(1, node[:12], tags, b('second in other'))]
92 93
93 self.assertEquals(other.summary(remote=True), d) 94 self.assertEquals(other.summary(remote=True), d)
94 95
95 def test_two_parents(self): 96 def test_two_parents(self):
96 self.append('a', 'a') 97 self.append('a', 'a')
97 rev0, node = self.client.commit('first', addremove=True) 98 rev0, node = self.client.commit(b('first'), addremove=True)
98 99
99 self.append('a', 'a') 100 self.append('a', 'a')
100 rev1, node1 = self.client.commit('second') 101 rev1, node1 = self.client.commit(b('second'))
101 102
102 self.client.update(rev0) 103 self.client.update(rev0)
103 self.append('b', 'a') 104 self.append('b', 'a')
104 rev2, node2 = self.client.commit('third', addremove=True) 105 rev2, node2 = self.client.commit(b('third'), addremove=True)
105 106
106 self.client.merge(rev1) 107 self.client.merge(rev1)
107 108
108 d = {'parent' : [(2, node2[:12], 'tip', 'third'), 109 d = {b('parent') : [(2, node2[:12], b('tip'), b('third')),
109 (1, node1[:12], None, 'second')], 110 (1, node1[:12], None, b('second'))],
110 'branch' : 'default', 111 b('branch') : b('default'),
111 'commit' : False, 112 b('commit') : False,
112 'update' : 0} 113 b('update') : 0}
113 114
114 self.assertEquals(self.client.summary(), d) 115 self.assertEquals(self.client.summary(), d)