# HG changeset patch # User Gregory Szorc # Date 1430931130 25200 # Node ID e6e7d1cce04da4ddff9d89794101eabb82640ede # Parent 890845af1ac28ae2958877a571a645bcb700a0b0 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. diff -r 890845af1ac2 -r e6e7d1cce04d mercurial/extensions.py --- a/mercurial/extensions.py Mon May 04 10:17:34 2015 +0900 +++ b/mercurial/extensions.py Wed May 06 09:52:10 2015 -0700 @@ -134,6 +134,10 @@ for fn in _aftercallbacks[shortname]: fn(loaded=False) + # loadall() is called multiple times and lingering _aftercallbacks + # entries could result in double execution. See issue4646. + _aftercallbacks.clear() + def afterloaded(extension, callback): '''Run the specified function after a named extension is loaded.