Mercurial > python-hglib
annotate tests/test-hidden.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 | 1b47146a4a2c |
children | 4359cabcb0cc |
rev | line source |
---|---|
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
1 import common, hglib, datetime |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
2 from hglib.error import CommandError |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
3 |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
4 class test_obsolete_reference(common.basetest): |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
5 """make sure obsolete changesets are disabled""" |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
6 def test_debugobsolete_failure(self): |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
7 f = open('gna1','w') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
8 f.write('g') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
9 f.close() |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
10 self.client.add('gna1') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
11 cs = self.client.commit('gna1')[1] #get id |
129
bcc8390d7819
tests: remove "with" usage for 2.4 compatibility
Matt Mackall <mpm@selenic.com>
parents:
124
diff
changeset
|
12 self.assertRaises(CommandError, |
bcc8390d7819
tests: remove "with" usage for 2.4 compatibility
Matt Mackall <mpm@selenic.com>
parents:
124
diff
changeset
|
13 self.client.rawcommand, ['debugobsolete', cs]) |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
14 |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
15 |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
16 class test_obsolete_baselib(common.basetest): |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
17 """base test class with obsolete changesets enabled""" |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
18 def setUp(self): |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
19 #create an extension which only activates obsolete |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
20 super(test_obsolete_baselib, self).setUp() |
134 | 21 self.append('.hg/obs.py', |
22 "import mercurial.obsolete\n" | |
23 "mercurial.obsolete._enabled = True") | |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
24 self.append('.hg/hgrc','\n[extensions]\nobs=.hg/obs.py') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
25 |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
26 class test_obsolete_client(test_obsolete_baselib): |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
27 """check client methods with obsolete changesets enabled""" |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
28 def test_debugobsolete_success(self): |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
29 """check the obsolete extension is available""" |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
30 self.append('gna1','ga') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
31 self.client.add('gna1') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
32 cs = self.client.commit('gna1')[1] #get id |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
33 self.client.rawcommand(['debugobsolete', cs]) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
34 |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
35 def test_obsolete_in(self): |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
36 """test the 'hidden' keyword with the 'in' method""" |
130
df808f92c0f1
tests: skip hidden/obsolete tests on older hg
Matt Mackall <mpm@selenic.com>
parents:
129
diff
changeset
|
37 if self.client.version < (2, 9, 0): |
df808f92c0f1
tests: skip hidden/obsolete tests on older hg
Matt Mackall <mpm@selenic.com>
parents:
129
diff
changeset
|
38 return |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
39 self.append('gna1','ga') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
40 self.client.add('gna1') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
41 cs0 = self.client.commit('gna1')[1] #get id |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
42 self.append('gna2','gaaa') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
43 self.client.add('gna2') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
44 cs1 = self.client.commit('gna2')[1] #get id |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
45 self.client.rawcommand(['debugobsolete', cs1]) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
46 self.client.update(cs0) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
47 self.assertFalse(cs1 in self.client) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
48 self.assertTrue(cs0 in self.client) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
49 self.client.hidden = True |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
50 self.assertTrue(cs1 in self.client) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
51 |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
52 class test_hidden_context(test_obsolete_baselib): |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
53 """test the "hidden" context method with obsolete changesets enabled on |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
54 hidden and visible changesets""" |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
55 def test_hidden(self): |
130
df808f92c0f1
tests: skip hidden/obsolete tests on older hg
Matt Mackall <mpm@selenic.com>
parents:
129
diff
changeset
|
56 if self.client.version < (2, 9, 0): |
df808f92c0f1
tests: skip hidden/obsolete tests on older hg
Matt Mackall <mpm@selenic.com>
parents:
129
diff
changeset
|
57 return |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
58 self.append('gna1','ga') |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
59 self.client.add('gna1') |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
60 cs0 = self.client.commit('gna1')[1] #get id |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
61 ctx0 = self.client[cs0] |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
62 self.append('gna2','gaaa') |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
63 self.client.add('gna2') |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
64 cs1 = self.client.commit('gna2')[1] #get id |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
65 ctx1 = self.client[cs1] |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
66 self.client.rawcommand(['debugobsolete', cs1]) |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
67 self.client.update(cs0) |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
68 self.assertTrue(ctx1.hidden()) |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
69 self.assertFalse(ctx0.hidden()) |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
70 |
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
71 |