Mercurial > hg
comparison mercurial/extensions.py @ 24950:e6e7d1cce04d stable
extensions: clear aftercallbacks after execution (issue4646)
It was reported that enabling pager without color could cause a hang.
Inserting print statements revealed that the callbacks in
extensions._aftercallbacks were being invoked twice.
extensions.loadall can be called multiple times. If entries in
extensions._aftercallbacks linger between calls, this could result
in double execution of the callbacks. This can lead to unwanted
behavior.
The reproduce steps in the bug seem to only occur when the output of
a command is less than the size of the current screen. This is not
something that can easily be tested. I verified the test case works
with this patch and that pager and color interaction continues to
work. Since we have no existing automated tests for pager, this sadly
appears to be the best testing I can do.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 06 May 2015 09:52:10 -0700 |
parents | fb6cb1b82f4f |
children | de23a552fc23 |
comparison
equal
deleted
inserted
replaced
24949:890845af1ac2 | 24950:e6e7d1cce04d |
---|---|
131 if shortname in _extensions: | 131 if shortname in _extensions: |
132 continue | 132 continue |
133 | 133 |
134 for fn in _aftercallbacks[shortname]: | 134 for fn in _aftercallbacks[shortname]: |
135 fn(loaded=False) | 135 fn(loaded=False) |
136 | |
137 # loadall() is called multiple times and lingering _aftercallbacks | |
138 # entries could result in double execution. See issue4646. | |
139 _aftercallbacks.clear() | |
136 | 140 |
137 def afterloaded(extension, callback): | 141 def afterloaded(extension, callback): |
138 '''Run the specified function after a named extension is loaded. | 142 '''Run the specified function after a named extension is loaded. |
139 | 143 |
140 If the named extension is already loaded, the callback will be called | 144 If the named extension is already loaded, the callback will be called |