Show More
@@ -1,8 +1,10 b'' | |||
|
1 | 1 | from __future__ import absolute_import |
|
2 | 2 | |
|
3 | import copy | |
|
3 | 4 | import os |
|
4 | 5 | import silenttestrunner |
|
5 | 6 | import tempfile |
|
7 | import types | |
|
6 | 8 | import unittest |
|
7 | 9 | |
|
8 | 10 | from mercurial import ( |
@@ -12,6 +14,12 b' from mercurial import (' | |||
|
12 | 14 | |
|
13 | 15 | testlockname = 'testlock' |
|
14 | 16 | |
|
17 | # work around http://bugs.python.org/issue1515 | |
|
18 | if types.MethodType not in copy._deepcopy_dispatch: | |
|
19 | def _deepcopy_method(x, memo): | |
|
20 | return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class) | |
|
21 | copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method | |
|
22 | ||
|
15 | 23 | class lockwrapper(lock.lock): |
|
16 | 24 | def __init__(self, pidoffset, *args, **kwargs): |
|
17 | 25 | # lock.lock.__init__() calls lock(), so the pidoffset assignment needs |
@@ -128,16 +136,16 b' class testlock(unittest.TestCase):' | |||
|
128 | 136 | state = teststate(self, tempfile.mkdtemp(dir=os.getcwd())) |
|
129 | 137 | lock = state.makelock() |
|
130 | 138 | state.assertacquirecalled(True) |
|
131 | lock.lock() | |
|
139 | ||
|
132 | 140 | # fake a fork |
|
133 | lock.pid += 1 | |
|
134 | lock.release() | |
|
141 | forklock = copy.deepcopy(lock) | |
|
142 | forklock._pidoffset = 1 | |
|
143 | forklock.release() | |
|
135 | 144 | state.assertreleasecalled(False) |
|
136 | 145 | state.assertpostreleasecalled(False) |
|
137 | 146 | state.assertlockexists(True) |
|
138 | 147 | |
|
139 | 148 | # release the actual lock |
|
140 | lock.pid -= 1 | |
|
141 | 149 | lock.release() |
|
142 | 150 | state.assertreleasecalled(True) |
|
143 | 151 | state.assertpostreleasecalled(True) |
General Comments 0
You need to be logged in to leave comments.
Login now