annotate tests/test-update.py @ 140:9c4f52467208

tests: disable largefiles test in update This never really worked because reposetup isn't called when we add an extension after the client session has started.
author Matt Mackall <mpm@selenic.com>
date Sat, 17 Jan 2015 17:54:40 -0800
parents 1b47146a4a2c
children 4359cabcb0cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import common
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2 from hglib import error
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 class test_update(common.basetest):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 def setUp(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 common.basetest.setUp(self)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 self.append('a', 'a')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8 self.rev0, self.node0 = self.client.commit('first', addremove=True)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 self.append('a', 'a')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.rev1, self.node1 = self.client.commit('second')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
11
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12 def test_basic(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 u, m, r, ur = self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.assertEquals(u, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 self.assertEquals(m, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 self.assertEquals(r, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self.assertEquals(ur, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 def test_unresolved(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 u, m, r, ur = self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 self.assertEquals(u, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
24 self.assertEquals(m, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 self.assertEquals(r, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 self.assertEquals(ur, 1)
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
27 self.assertTrue(('M', 'a') in self.client.status())
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 def test_merge(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 self.append('a', '\n\n\n\nb')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31 rev2, node2 = self.client.commit('third')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33 self.client.commit('fourth')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34 self.client.update(rev2)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
35 old = open('a').read()
118
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
36 f = open('a', 'wb')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
37 f.write('a' + old)
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
38 f.close()
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
39 u, m, r, ur = self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40 self.assertEquals(u, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
41 self.assertEquals(m, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
42 self.assertEquals(r, 0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
43 self.assertEquals(ur, 0)
34
f6e1d9a6e0cd client: change return value of status() to a list of (code, file path)
Idan Kamara <idankk86@gmail.com>
parents: 20
diff changeset
44 self.assertEquals(self.client.status(), [('M', 'a')])
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
46 def test_tip(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
47 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
48 u, m, r, ur = self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
49 self.assertEquals(u, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
50 self.assertEquals(self.client.parents()[0].node, self.node1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
52 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
53 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
54 rev2, node2 = self.client.commit('new head')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
55 self.client.update(self.rev0)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
56
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
57 self.client.update()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
58 self.assertEquals(self.client.parents()[0].node, node2)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
60 def test_check_clean(self):
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 118
diff changeset
61 self.assertRaises(ValueError, self.client.update, clean=True,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 118
diff changeset
62 check=True)
20
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
63
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
64 def test_clean(self):
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
65 old = open('a').read()
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
66 self.append('a', 'b')
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
67 self.assertRaises(error.CommandError, self.client.update, check=True)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
68
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
69 u, m, r, ur = self.client.update(clean=True)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
70 self.assertEquals(u, 1)
6a9d16ddae31 client: add update command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
71 self.assertEquals(old, open('a').read())
105
86ff8611a8fa client: always set HGPLAIN=1 (issue3502)
Siddharth Agarwal <sid0@fb.com>
parents: 68
diff changeset
72
86ff8611a8fa client: always set HGPLAIN=1 (issue3502)
Siddharth Agarwal <sid0@fb.com>
parents: 68
diff changeset
73 def test_basic_plain(self):
118
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
74 f = open('.hg/hgrc', 'a')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
75 f.write('[defaults]\nupdate=-v\n')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
76 f.close()
105
86ff8611a8fa client: always set HGPLAIN=1 (issue3502)
Siddharth Agarwal <sid0@fb.com>
parents: 68
diff changeset
77 self.test_basic()
109
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
78
140
9c4f52467208 tests: disable largefiles test in update
Matt Mackall <mpm@selenic.com>
parents: 134
diff changeset
79 def disabled_largefiles(self):
9c4f52467208 tests: disable largefiles test in update
Matt Mackall <mpm@selenic.com>
parents: 134
diff changeset
80 # we don't run reposetup after a session has started, so this
9c4f52467208 tests: disable largefiles test in update
Matt Mackall <mpm@selenic.com>
parents: 134
diff changeset
81 # test is broken
109
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
82 import os
118
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
83 f = open('.hg/hgrc', 'a')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
84 f.write('[extensions]\nlargefiles=\n')
e738d6fe5f3f tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents: 115
diff changeset
85 f.close()
109
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
86 self.append('b', 'a')
115
8867908fe8c7 tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents: 109
diff changeset
87 try:
8867908fe8c7 tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents: 109
diff changeset
88 self.client.rawcommand(['add', 'b', '--large'])
8867908fe8c7 tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents: 109
diff changeset
89 except error.CommandError:
8867908fe8c7 tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents: 109
diff changeset
90 return
8867908fe8c7 tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents: 109
diff changeset
91
109
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
92 rev2, node2 = self.client.commit('third')
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
93 # Go back to 0
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
94 self.client.rawcommand(['update', str(self.rev0)],
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
95 # Keep the 'changed' version
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
96 prompt=lambda s, d: 'c\n')
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
97 u, m, r, ur = self.client.update(rev2, clean=True)
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
98 self.assertEquals(u, 2)
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
99 self.assertEquals(m, 0)
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
100 self.assertEquals(r, 0)
9324a89dd84e client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents: 105
diff changeset
101 self.assertEquals(ur, 0)