annotate tests/common.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 d1a42c1d0b61
children 1b47146a4a2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
1 import os, sys, tempfile, shutil
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
2 import unittest
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 import hglib
101
d1a42c1d0b61 tests: hook into hgclient.open for closing open cmdservers
Idan Kamara <idankk86@gmail.com>
parents: 68
diff changeset
5 from hglib import client
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6
67
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
7 def resultappender(list):
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
8 def decorator(f):
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
9 def decorated(*args, **kwargs):
101
d1a42c1d0b61 tests: hook into hgclient.open for closing open cmdservers
Idan Kamara <idankk86@gmail.com>
parents: 68
diff changeset
10 list.append(args[0])
d1a42c1d0b61 tests: hook into hgclient.open for closing open cmdservers
Idan Kamara <idankk86@gmail.com>
parents: 68
diff changeset
11 return f(*args, **kwargs)
67
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
12 return decorated
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
13 return decorator
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
14
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
15 class basetest(unittest.TestCase):
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16 def setUp(self):
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 self._testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 os.path.join(os.environ["HGTMP"], self.__class__.__name__)
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19
67
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
20 self.clients = []
101
d1a42c1d0b61 tests: hook into hgclient.open for closing open cmdservers
Idan Kamara <idankk86@gmail.com>
parents: 68
diff changeset
21 self._oldopen = hglib.client.hgclient.open
d1a42c1d0b61 tests: hook into hgclient.open for closing open cmdservers
Idan Kamara <idankk86@gmail.com>
parents: 68
diff changeset
22 # hglib.open = resultappender(self.clients)(hglib.open)
d1a42c1d0b61 tests: hook into hgclient.open for closing open cmdservers
Idan Kamara <idankk86@gmail.com>
parents: 68
diff changeset
23 hglib.client.hgclient.open = resultappender(self.clients)(hglib.client.hgclient.open)
67
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
24
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25 os.mkdir(self._testtmp)
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
26 os.chdir(self._testtmp)
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27 # until we can run norepo commands in the cmdserver
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28 os.system('hg init')
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 self.client = hglib.open()
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31 def tearDown(self):
67
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
32 # on Windows we cannot rmtree before closing all instances because of used
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
33 # files
101
d1a42c1d0b61 tests: hook into hgclient.open for closing open cmdservers
Idan Kamara <idankk86@gmail.com>
parents: 68
diff changeset
34 hglib.client.hgclient.open = self._oldopen
67
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
35 for client in self.clients:
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
36 if client.server is not None:
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
37 client.close()
730c42743ba3 tests: cleanup on test finish so Windows doesn't complain about used files
Idan Kamara <idankk86@gmail.com>
parents: 58
diff changeset
38 os.chdir('..')
58
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
39 try:
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
40 shutil.rmtree(self._testtmp)
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
41 except AttributeError:
3d413c54e048 tests: be prepared for basetest.setUp not being called
Idan Kamara <idankk86@gmail.com>
parents: 7
diff changeset
42 pass # if our setUp was overriden
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
43
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
44 def append(self, path, *args):
68
a0328b08e028 tests: open files in binary mode so new lines aren't converted
Idan Kamara <idankk86@gmail.com>
parents: 67
diff changeset
45 f = open(path, 'ab')
7
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
46 for a in args:
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
47 f.write(str(a))
eac8be119d81 tests: rearrange tests and use nosetests
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
48 f.close()