annotate tests/test-update.py @ 144:3c59643a2bc3

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