Mercurial > python-hglib
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-hidden.py Thu May 22 15:23:12 2014 +0200 @@ -0,0 +1,43 @@ +import common, hglib, datetime +from hglib.error import CommandError + +class test_obsolete_reference(common.basetest): + '''make sure obsolete changesets are disabled''' + def test_debugobsolete_failure(self): + f = open('gna1','w') + f.write('g') + f.close() + self.client.add('gna1') + cs = self.client.commit('gna1')[1] #get id + with self.assertRaises(CommandError): + self.client.rawcommand(['debugobsolete', cs]) + + +class test_obsolete(common.basetest): + '''test a few client methods with obsolete changesets enabled''' + def setUp(self): + #create an extension which only activates obsolete + super(test_obsolete, self).setUp() + self.append('.hg/obs.py','''import mercurial.obsolete\nmercurial.obsolete._enabled = True''') + self.append('.hg/hgrc','\n[extensions]\nobs=.hg/obs.py') + + def test_debugobsolete_success(self): + self.append('gna1','ga') + self.client.add('gna1') + cs = self.client.commit('gna1')[1] #get id + self.client.rawcommand(['debugobsolete', cs]) + + def test_obsolete_in(self): + self.append('gna1','ga') + self.client.add('gna1') + cs0 = self.client.commit('gna1')[1] #get id + self.append('gna2','gaaa') + self.client.add('gna2') + cs1 = self.client.commit('gna2')[1] #get id + self.client.rawcommand(['debugobsolete', cs1]) + self.client.update(cs0) + self.assertFalse(cs1 in self.client) + self.assertTrue(cs0 in self.client) + self.client.hidden = True + self.assertTrue(cs1 in self.client) +