Show More
@@ -0,0 +1,49 b'' | |||||
|
1 | ||||
|
2 | $ cat << EOF > buggylocking.py | |||
|
3 | > """A small extension that acquire locks in the wrong order | |||
|
4 | > """ | |||
|
5 | > | |||
|
6 | > from mercurial import cmdutil | |||
|
7 | > | |||
|
8 | > cmdtable = {} | |||
|
9 | > command = cmdutil.command(cmdtable) | |||
|
10 | > | |||
|
11 | > @command('buggylocking', [], '') | |||
|
12 | > def buggylocking(ui, repo): | |||
|
13 | > lo = repo.lock() | |||
|
14 | > wl = repo.wlock() | |||
|
15 | > EOF | |||
|
16 | ||||
|
17 | $ cat << EOF >> $HGRCPATH | |||
|
18 | > [extensions] | |||
|
19 | > buggylocking=$TESTTMP/buggylocking.py | |||
|
20 | > [devel] | |||
|
21 | > all=1 | |||
|
22 | > EOF | |||
|
23 | ||||
|
24 | $ hg init lock-checker | |||
|
25 | $ cd lock-checker | |||
|
26 | $ hg buggylocking | |||
|
27 | "lock" taken before "wlock" | |||
|
28 | $ cat << EOF >> $HGRCPATH | |||
|
29 | > [devel] | |||
|
30 | > all=0 | |||
|
31 | > check-locks=1 | |||
|
32 | > EOF | |||
|
33 | $ hg buggylocking | |||
|
34 | "lock" taken before "wlock" | |||
|
35 | $ hg buggylocking --traceback | |||
|
36 | "lock" taken before "wlock" | |||
|
37 | at: | |||
|
38 | */hg:* in <module> (glob) | |||
|
39 | */mercurial/dispatch.py:* in run (glob) | |||
|
40 | */mercurial/dispatch.py:* in dispatch (glob) | |||
|
41 | */mercurial/dispatch.py:* in _runcatch (glob) | |||
|
42 | */mercurial/dispatch.py:* in _dispatch (glob) | |||
|
43 | */mercurial/dispatch.py:* in runcommand (glob) | |||
|
44 | */mercurial/dispatch.py:* in _runcommand (glob) | |||
|
45 | */mercurial/dispatch.py:* in checkargs (glob) | |||
|
46 | */mercurial/dispatch.py:* in <lambda> (glob) | |||
|
47 | */mercurial/util.py:* in check (glob) | |||
|
48 | $TESTTMP/buggylocking.py:* in buggylocking (glob) | |||
|
49 | $ cd .. |
@@ -1189,6 +1189,15 b' class localrepository(object):' | |||||
1189 | '''Lock the non-store parts of the repository (everything under |
|
1189 | '''Lock the non-store parts of the repository (everything under | |
1190 | .hg except .hg/store) and return a weak reference to the lock. |
|
1190 | .hg except .hg/store) and return a weak reference to the lock. | |
1191 | Use this before modifying files in .hg.''' |
|
1191 | Use this before modifying files in .hg.''' | |
|
1192 | if (self.ui.configbool('devel', 'all') | |||
|
1193 | or self.ui.configbool('devel', 'check-locks')): | |||
|
1194 | l = self._lockref and self._lockref() | |||
|
1195 | if l is not None and l.held: | |||
|
1196 | msg = '"lock" taken before "wlock"\n' | |||
|
1197 | if self.ui.tracebackflag: | |||
|
1198 | util.debugstacktrace(msg, 1) | |||
|
1199 | else: | |||
|
1200 | self.ui.write_err(msg) | |||
1192 | l = self._wlockref and self._wlockref() |
|
1201 | l = self._wlockref and self._wlockref() | |
1193 | if l is not None and l.held: |
|
1202 | if l is not None and l.held: | |
1194 | l.lock() |
|
1203 | l.lock() |
General Comments 0
You need to be logged in to leave comments.
Login now