##// END OF EJS Templates
lock: allow to configure when the lock messages are displayed...
Boris Feld -
r35210:9153871d default
parent child Browse files
Show More
@@ -1081,6 +1081,9 b" coreconfigitem('ui', 'textwidth',"
1081 coreconfigitem('ui', 'timeout',
1081 coreconfigitem('ui', 'timeout',
1082 default='600',
1082 default='600',
1083 )
1083 )
1084 coreconfigitem('ui', 'timeout.warn',
1085 default=0,
1086 )
1084 coreconfigitem('ui', 'traceback',
1087 coreconfigitem('ui', 'traceback',
1085 default=False,
1088 default=False,
1086 )
1089 )
@@ -2215,6 +2215,10 b' User interface controls.'
2215 The timeout used when a lock is held (in seconds), a negative value
2215 The timeout used when a lock is held (in seconds), a negative value
2216 means no timeout. (default: 600)
2216 means no timeout. (default: 600)
2217
2217
2218 ``timeout.warn``
2219 Time (in seconds) before a warning is printed about held lock. A negative
2220 value means no warning. (default: 0)
2221
2218 ``traceback``
2222 ``traceback``
2219 Mercurial always prints a traceback when an unknown exception
2223 Mercurial always prints a traceback when an unknown exception
2220 occurs. Setting this to True will make Mercurial print a traceback
2224 occurs. Setting this to True will make Mercurial print a traceback
@@ -1594,10 +1594,12 b' class localrepository(object):'
1594 parentlock = encoding.environ.get(parentenvvar)
1594 parentlock = encoding.environ.get(parentenvvar)
1595
1595
1596 timeout = 0
1596 timeout = 0
1597 warntimeout = 0
1597 if wait:
1598 if wait:
1598 timeout = self.ui.configint("ui", "timeout")
1599 timeout = self.ui.configint("ui", "timeout")
1600 warntimeout = self.ui.configint("ui", "timeout.warn")
1599
1601
1600 l = lockmod.trylock(self.ui, vfs, lockname, timeout,
1602 l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout,
1601 releasefn=releasefn,
1603 releasefn=releasefn,
1602 acquirefn=acquirefn, desc=desc,
1604 acquirefn=acquirefn, desc=desc,
1603 inheritchecker=inheritchecker,
1605 inheritchecker=inheritchecker,
@@ -41,11 +41,11 b' def _getlockprefix():'
41 raise
41 raise
42 return result
42 return result
43
43
44 def trylock(ui, vfs, lockname, timeout, *args, **kwargs):
44 def trylock(ui, vfs, lockname, timeout, warntimeout, *args, **kwargs):
45 """return an acquired lock or raise an a LockHeld exception
45 """return an acquired lock or raise an a LockHeld exception
46
46
47 This function is responsible to issue warnings about the held lock while
47 This function is responsible to issue warnings and or debug messages about
48 trying to acquires it."""
48 the held lock while trying to acquires it."""
49
49
50 def printwarning(printer, locker):
50 def printwarning(printer, locker):
51 """issue the usual "waiting on lock" message through any channel"""
51 """issue the usual "waiting on lock" message through any channel"""
@@ -60,9 +60,12 b' def trylock(ui, vfs, lockname, timeout, '
60
60
61 l = lock(vfs, lockname, 0, *args, dolock=False, **kwargs)
61 l = lock(vfs, lockname, 0, *args, dolock=False, **kwargs)
62
62
63 debugidx = 0 if (warntimeout and timeout) else -1
63 warningidx = 0
64 warningidx = 0
64 if not timeout:
65 if not timeout:
65 warningidx = -1
66 warningidx = -1
67 elif warntimeout:
68 warningidx = warntimeout
66
69
67 delay = 0
70 delay = 0
68 while True:
71 while True:
@@ -70,6 +73,8 b' def trylock(ui, vfs, lockname, timeout, '
70 l._trylock()
73 l._trylock()
71 break
74 break
72 except error.LockHeld as inst:
75 except error.LockHeld as inst:
76 if delay == debugidx:
77 printwarning(ui.debug, inst.locker)
73 if delay == warningidx:
78 if delay == warningidx:
74 printwarning(ui.warn, inst.locker)
79 printwarning(ui.warn, inst.locker)
75 if timeout <= delay:
80 if timeout <= delay:
@@ -80,7 +85,10 b' def trylock(ui, vfs, lockname, timeout, '
80
85
81 l.delay = delay
86 l.delay = delay
82 if l.delay:
87 if l.delay:
83 ui.warn(_("got lock after %s seconds\n") % l.delay)
88 if 0 <= warningidx <= l.delay:
89 ui.warn(_("got lock after %s seconds\n") % l.delay)
90 else:
91 ui.debug("got lock after %s seconds\n" % l.delay)
84 if l.acquirefn:
92 if l.acquirefn:
85 l.acquirefn()
93 l.acquirefn()
86 return l
94 return l
@@ -57,14 +57,77 b' One process waiting for another'
57 $ echo b > b/b
57 $ echo b > b/b
58 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
58 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
59 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
59 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
60 > > preup 2>&1
60 > > preup-stdout 2>preup-stderr
61 $ wait
61 $ wait
62 $ cat preup
62 $ cat preup-stdout
63 $ cat preup-stderr
63 waiting for lock on working directory of b held by process '*' on host '*' (glob)
64 waiting for lock on working directory of b held by process '*' on host '*' (glob)
64 got lock after * seconds (glob)
65 got lock after * seconds (glob)
65 $ cat stdout
66 $ cat stdout
66 adding b
67 adding b
67
68
69 On processs waiting on another, warning after a long time.
70
71 $ echo b > b/c
72 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
73 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
74 > --config ui.timeout.warn=250 \
75 > > preup-stdout 2>preup-stderr
76 $ wait
77 $ cat preup-stdout
78 $ cat preup-stderr
79 $ cat stdout
80 adding c
81
82 On processs waiting on another, warning disabled.
83
84 $ echo b > b/d
85 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
86 $ hg -R b up -q --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
87 > --config ui.timeout.warn=-1 \
88 > > preup-stdout 2>preup-stderr
89 $ wait
90 $ cat preup-stdout
91 $ cat preup-stderr
92 $ cat stdout
93 adding d
94
95 check we still print debug output
96
97 On processs waiting on another, warning after a long time (debug output on)
98
99 $ echo b > b/e
100 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
101 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
102 > --config ui.timeout.warn=250 --debug\
103 > > preup-stdout 2>preup-stderr
104 $ wait
105 $ cat preup-stdout
106 calling hook pre-update: hghook_pre-update.sleephalf
107 waiting for lock on working directory of b held by process '*' on host '*' (glob)
108 got lock after * seconds (glob)
109 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
110 $ cat preup-stderr
111 $ cat stdout
112 adding e
113
114 On processs waiting on another, warning disabled, (debug output on)
115
116 $ echo b > b/f
117 $ hg -R b ci -A -m b --config hooks.precommit="python:`pwd`/hooks.py:sleepone" > stdout &
118 $ hg -R b up --config hooks.pre-update="python:`pwd`/hooks.py:sleephalf" \
119 > --config ui.timeout.warn=-1 --debug\
120 > > preup-stdout 2>preup-stderr
121 $ wait
122 $ cat preup-stdout
123 calling hook pre-update: hghook_pre-update.sleephalf
124 waiting for lock on working directory of b held by process '*' on host '*' (glob)
125 got lock after * seconds (glob)
126 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
127 $ cat preup-stderr
128 $ cat stdout
129 adding f
130
68 Pushing to a local read-only repo that can't be locked
131 Pushing to a local read-only repo that can't be locked
69
132
70 $ chmod 100 a/.hg/store
133 $ chmod 100 a/.hg/store
General Comments 0
You need to be logged in to leave comments. Login now