Mercurial > python-hglib
annotate tests/test-update.py @ 124:cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
This method should not be a static property obtained at creation as the hidden
status may change.
author | Paul Tonelli <paul.tonelli@logilab.fr> |
---|---|
date | Thu, 15 May 2014 15:12:13 +0200 |
parents | e738d6fe5f3f |
children | 1b47146a4a2c |
rev | line source |
---|---|
20 | 1 import common |
2 from hglib import error | |
3 | |
4 class test_update(common.basetest): | |
5 def setUp(self): | |
6 common.basetest.setUp(self) | |
7 self.append('a', 'a') | |
8 self.rev0, self.node0 = self.client.commit('first', addremove=True) | |
9 self.append('a', 'a') | |
10 self.rev1, self.node1 = self.client.commit('second') | |
11 | |
12 def test_basic(self): | |
13 u, m, r, ur = self.client.update(self.rev0) | |
14 self.assertEquals(u, 1) | |
15 self.assertEquals(m, 0) | |
16 self.assertEquals(r, 0) | |
17 self.assertEquals(ur, 0) | |
18 | |
19 def test_unresolved(self): | |
20 self.client.update(self.rev0) | |
21 self.append('a', 'b') | |
22 u, m, r, ur = self.client.update() | |
23 self.assertEquals(u, 0) | |
24 self.assertEquals(m, 0) | |
25 self.assertEquals(r, 0) | |
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 | 28 |
29 def test_merge(self): | |
30 self.append('a', '\n\n\n\nb') | |
31 rev2, node2 = self.client.commit('third') | |
32 self.append('a', 'b') | |
33 self.client.commit('fourth') | |
34 self.client.update(rev2) | |
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 | 39 u, m, r, ur = self.client.update() |
40 self.assertEquals(u, 0) | |
41 self.assertEquals(m, 1) | |
42 self.assertEquals(r, 0) | |
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 | 45 |
46 def test_tip(self): | |
47 self.client.update(self.rev0) | |
48 u, m, r, ur = self.client.update() | |
49 self.assertEquals(u, 1) | |
50 self.assertEquals(self.client.parents()[0].node, self.node1) | |
51 | |
52 self.client.update(self.rev0) | |
53 self.append('a', 'b') | |
54 rev2, node2 = self.client.commit('new head') | |
55 self.client.update(self.rev0) | |
56 | |
57 self.client.update() | |
58 self.assertEquals(self.client.parents()[0].node, node2) | |
59 | |
60 def test_check_clean(self): | |
61 self.assertRaises(ValueError, self.client.update, clean=True, check=True) | |
62 | |
63 def test_clean(self): | |
64 old = open('a').read() | |
65 self.append('a', 'b') | |
66 self.assertRaises(error.CommandError, self.client.update, check=True) | |
67 | |
68 u, m, r, ur = self.client.update(clean=True) | |
69 self.assertEquals(u, 1) | |
70 self.assertEquals(old, open('a').read()) | |
105
86ff8611a8fa
client: always set HGPLAIN=1 (issue3502)
Siddharth Agarwal <sid0@fb.com>
parents:
68
diff
changeset
|
71 |
86ff8611a8fa
client: always set HGPLAIN=1 (issue3502)
Siddharth Agarwal <sid0@fb.com>
parents:
68
diff
changeset
|
72 def test_basic_plain(self): |
118
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
115
diff
changeset
|
73 f = open('.hg/hgrc', 'a') |
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
115
diff
changeset
|
74 f.write('[defaults]\nupdate=-v\n') |
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
115
diff
changeset
|
75 f.close() |
105
86ff8611a8fa
client: always set HGPLAIN=1 (issue3502)
Siddharth Agarwal <sid0@fb.com>
parents:
68
diff
changeset
|
76 self.test_basic() |
109
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
77 |
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
78 def test_largefiles(self): |
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
79 import os |
118
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
115
diff
changeset
|
80 f = open('.hg/hgrc', 'a') |
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
115
diff
changeset
|
81 f.write('[extensions]\nlargefiles=\n') |
e738d6fe5f3f
tests: make the tests work under Pypy (issue3965)
Matt Mackall <mpm@selenic.com>
parents:
115
diff
changeset
|
82 f.close() |
109
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
83 self.append('b', 'a') |
115
8867908fe8c7
tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents:
109
diff
changeset
|
84 try: |
8867908fe8c7
tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents:
109
diff
changeset
|
85 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
|
86 except error.CommandError: |
8867908fe8c7
tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents:
109
diff
changeset
|
87 return |
8867908fe8c7
tests: deal with missing largefiles support for 1.9
Matt Mackall <mpm@selenic.com>
parents:
109
diff
changeset
|
88 |
109
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
89 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
|
90 # Go back to 0 |
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
91 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
|
92 # Keep the 'changed' version |
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
93 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
|
94 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
|
95 self.assertEquals(u, 2) |
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
96 self.assertEquals(m, 0) |
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
97 self.assertEquals(r, 0) |
9324a89dd84e
client: Be more permissive on the output of update (issue3892)
Benoit Allard <benoit@aeteurope.nl>
parents:
105
diff
changeset
|
98 self.assertEquals(ur, 0) |