annotate tests/test-hidden.py @ 123:cdde1656346f

client: add 'hidden' property to show hidden changesets. This enables interactions with the obsolete changesets in the repository: - add the attribute in client class - add the keyword to the relevant commands - enable log without hidden changesets even when self.hidden is True - add a few tests with the hidden keyword This changeset mirrors the behavior of the mercurial global command --hidden: an attribute is added to the client library. If set at True, adds the hidden keyword to all command which can use it to show hidden changesets. The alternative would be to add the keyword in rawcommand, but the hidden flag is not relevant for commands such as add or branch.
author Paul Tonelli <paul.tonelli@logilab.fr>
date Thu, 22 May 2014 15:23:12 +0200
parents
children cc7569bffb26
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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):
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
5 '''make sure obsolete changesets are disabled'''
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
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
12 with self.assertRaises(CommandError):
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
13 self.client.rawcommand(['debugobsolete', cs])
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
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
16 class test_obsolete(common.basetest):
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
17 '''test a few client methods with obsolete changesets enabled'''
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
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
20 super(test_obsolete, self).setUp()
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
21 self.append('.hg/obs.py','''import mercurial.obsolete\nmercurial.obsolete._enabled = True''')
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
22 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
23
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
24 def test_debugobsolete_success(self):
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
25 self.append('gna1','ga')
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
26 self.client.add('gna1')
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
27 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
28 self.client.rawcommand(['debugobsolete', cs])
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
29
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
30 def test_obsolete_in(self):
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
31 self.append('gna1','ga')
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
32 self.client.add('gna1')
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
33 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
34 self.append('gna2','gaaa')
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
35 self.client.add('gna2')
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
36 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
37 self.client.rawcommand(['debugobsolete', cs1])
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
38 self.client.update(cs0)
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
39 self.assertFalse(cs1 in self.client)
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
40 self.assertTrue(cs0 in self.client)
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
41 self.client.hidden = True
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
42 self.assertTrue(cs1 in self.client)
cdde1656346f client: add 'hidden' property to show hidden changesets.
Paul Tonelli <paul.tonelli@logilab.fr>
parents:
diff changeset
43