Mercurial > python-hglib
annotate tests/test-hidden.py @ 208:12e6aaef0f6e
tests: handle the removal of `obsolete._enabled` in Mercurial
I'm not sure why we can't just set `experimental.evolution=all`, but it didn't
work.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 07 May 2019 22:16:59 -0400 |
parents | c1b966866ed7 |
children |
rev | line source |
---|---|
148
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
1 from tests import common |
c1b966866ed7
hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents:
143
diff
changeset
|
2 import hglib, datetime |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
3 from hglib.error import CommandError |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
4 from hglib.util import b |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
5 |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
6 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
|
7 """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
|
8 def test_debugobsolete_failure(self): |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
9 f = open('gna1','w') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
10 f.write('g') |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
11 f.close() |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
12 self.client.add(b('gna1')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
13 cs = self.client.commit(b('gna1'))[1] #get id |
129
bcc8390d7819
tests: remove "with" usage for 2.4 compatibility
Matt Mackall <mpm@selenic.com>
parents:
124
diff
changeset
|
14 self.assertRaises(CommandError, |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
15 self.client.rawcommand, [b('debugobsolete'), cs]) |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
16 |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
17 |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
18 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
|
19 """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
|
20 def setUp(self): |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
21 #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
|
22 super(test_obsolete_baselib, self).setUp() |
134 | 23 self.append('.hg/obs.py', |
24 "import mercurial.obsolete\n" | |
208
12e6aaef0f6e
tests: handle the removal of `obsolete._enabled` in Mercurial
Matt Harbison <matt_harbison@yahoo.com>
parents:
148
diff
changeset
|
25 "# 3.2 and later\n" |
12e6aaef0f6e
tests: handle the removal of `obsolete._enabled` in Mercurial
Matt Harbison <matt_harbison@yahoo.com>
parents:
148
diff
changeset
|
26 "mercurial.obsolete.isenabled = lambda r, opt: True\n" |
12e6aaef0f6e
tests: handle the removal of `obsolete._enabled` in Mercurial
Matt Harbison <matt_harbison@yahoo.com>
parents:
148
diff
changeset
|
27 "# Dropped in 5.1\n" |
134 | 28 "mercurial.obsolete._enabled = True") |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
29 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
|
30 |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
31 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
|
32 """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
|
33 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
|
34 """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
|
35 self.append('gna1','ga') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
36 self.client.add(b('gna1')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
37 cs = self.client.commit(b('gna1'))[1] #get id |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
38 self.client.rawcommand([b('debugobsolete'), cs]) |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
39 |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
40 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
|
41 """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
|
42 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
|
43 return |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
44 self.append('gna1','ga') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
45 self.client.add(b('gna1')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
46 cs0 = self.client.commit(b('gna1'))[1] #get id |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
47 self.append('gna2','gaaa') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
48 self.client.add(b('gna2')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
49 cs1 = self.client.commit(b('gna2'))[1] #get id |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
50 self.client.rawcommand([b('debugobsolete'), cs1]) |
123
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
51 self.client.update(cs0) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
52 self.assertFalse(cs1 in self.client) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
53 self.assertTrue(cs0 in self.client) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
54 self.client.hidden = True |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
55 self.assertTrue(cs1 in self.client) |
cdde1656346f
client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff
changeset
|
56 |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
57 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
|
58 """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
|
59 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
|
60 def test_hidden(self): |
130
df808f92c0f1
tests: skip hidden/obsolete tests on older hg
Matt Mackall <mpm@selenic.com>
parents:
129
diff
changeset
|
61 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
|
62 return |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
63 self.append('gna1','ga') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
64 self.client.add(b('gna1')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
65 cs0 = self.client.commit(b('gna1'))[1] #get id |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
66 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
|
67 self.append('gna2','gaaa') |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
68 self.client.add(b('gna2')) |
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
69 cs1 = self.client.commit(b('gna2'))[1] #get id |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
70 ctx1 = self.client[cs1] |
143
4359cabcb0cc
hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents:
134
diff
changeset
|
71 self.client.rawcommand([b('debugobsolete'), cs1]) |
124
cc7569bffb26
context: add 'hidden' method to check if the changeset is hidden
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
123
diff
changeset
|
72 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
|
73 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
|
74 self.assertFalse(ctx0.hidden()) |