annotate tests/test-summary.py @ 142:fe74d5599539

hglib: wrap all application string literals in util.b() (issue4520) Conversion also included changing use of string interpolation to string concatenation as bytes interpolation does not exist in Python 3. Indexing related to bytes was also changed to length-1 bytes through slicing as Python 3 returns an int in this instance. Tests have not been switched to using util.b() so that the change to application code can be independently verified as not being broken.
author Brett Cannon <brett@python.org>
date Sun, 08 Mar 2015 13:08:37 -0400
parents 3bbf6a3266f4
children 4359cabcb0cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import common
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2 import hglib
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 class test_summary(common.basetest):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 def test_empty(self):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 d = {'parent' : [(-1, '000000000000', 'tip', None)],
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 'branch' : 'default',
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 'commit' : True,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 'update' : 0}
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11 self.assertEquals(self.client.summary(), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 def test_basic(self):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 rev, node = self.client.commit('first', addremove=True)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 d = {'parent' : [(0, node[:12], 'tip', 'first')],
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 'branch' : 'default',
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 'commit' : True,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 'update' : 0}
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 self.assertEquals(self.client.summary(), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 def test_commit_dirty(self):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 rev, node = self.client.commit('first', addremove=True)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 d = {'parent' : [(0, node[:12], 'tip', 'first')],
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 'branch' : 'default',
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31 'commit' : False,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32 'update' : 0}
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34 self.assertEquals(self.client.summary(), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
35
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
36 def test_update(self):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
37 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
38 rev, node = self.client.commit('first', addremove=True)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
39 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40 self.client.commit('second')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
41 self.client.update(0)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
42
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
43 d = {'parent' : [(0, node[:12], None, 'first')],
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
44 'branch' : 'default',
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45 'commit' : True,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
46 'update' : 1}
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
47
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
48 self.assertEquals(self.client.summary(), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
49
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
50 def test_remote(self):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
52 rev, node = self.client.commit('first', addremove=True)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
53
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
54 self.client.clone(dest='other')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
55 other = hglib.open('other')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
56
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
57 d = {'parent' : [(0, node[:12], 'tip', 'first')],
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
58 'branch' : 'default',
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59 'commit' : True,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
60 'update' : 0,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
61 'remote' : (0, 0, 0, 0)}
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
62
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
63 self.assertEquals(other.summary(remote=True), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
64
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
65 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
66 self.client.commit('second')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
67
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
68 d['remote'] = (1, 0, 0, 0)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
69 self.assertEquals(other.summary(remote=True), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
70
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
71 self.client.bookmark('bm')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
72 d['remote'] = (1, 1, 0, 0)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
73 self.assertEquals(other.summary(remote=True), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
74
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
75 other.bookmark('bmother')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
76 d['remote'] = (1, 1, 0, 1)
88
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
77 if self.client.version < (2, 0, 0):
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
78 d['parent'] = [(0, node[:12], 'tip bmother', 'first')]
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
79 else:
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
80 d['bookmarks'] = '*bmother'
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
81 self.assertEquals(other.summary(remote=True), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
82
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
83 self.append('other/a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
84 rev, node = other.commit('second in other')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
85
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
86 d['remote'] = (1, 1, 1, 1)
88
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
87 if self.client.version < (2, 0, 0):
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
88 tags = 'tip bmother'
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
89 else:
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
90 tags = 'tip'
3bbf6a3266f4 test-summary: fix test due to bookmarks being separated from tags in hg >= 2.0
Idan Kamara <idankk86@gmail.com>
parents: 51
diff changeset
91 d['parent'] = [(1, node[:12], tags, 'second in other')]
51
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
92
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
93 self.assertEquals(other.summary(remote=True), d)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
94
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
95 def test_two_parents(self):
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
96 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
97 rev0, node = self.client.commit('first', addremove=True)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
98
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
99 self.append('a', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
100 rev1, node1 = self.client.commit('second')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
101
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
102 self.client.update(rev0)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
103 self.append('b', 'a')
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
104 rev2, node2 = self.client.commit('third', addremove=True)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
105
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
106 self.client.merge(rev1)
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
107
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
108 d = {'parent' : [(2, node2[:12], 'tip', 'third'),
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
109 (1, node1[:12], None, 'second')],
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
110 'branch' : 'default',
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
111 'commit' : False,
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
112 'update' : 0}
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
113
c52383a550fb client: add summary command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
114 self.assertEquals(self.client.summary(), d)