components/mercurial/patches/issue4646.patch
branchs11-update
changeset 4321 38b0ccd2f460
equal deleted inserted replaced
4318:7f2f7aebce6e 4321:38b0ccd2f460
       
     1 # HG changeset patch
       
     2 # User Gregory Szorc <[email protected]>
       
     3 # Date 1430931130 25200
       
     4 #      Wed May 06 09:52:10 2015 -0700
       
     5 # Branch stable
       
     6 # Node ID 44b054c3a46eac63d5fed06ffb8fffc38d5668f6
       
     7 # Parent  41cd8171e58f991373dcd0b4897dc1e5978d42dd
       
     8 extensions: clear aftercallbacks after execution (issue4646)
       
     9 
       
    10 It was reported that enabling pager without color could cause a hang.
       
    11 Inserting print statements revealed that the callbacks in
       
    12 extensions._aftercallbacks were being invoked twice.
       
    13 
       
    14 extensions.loadall can be called multiple times. If entries in
       
    15 extensions._aftercallbacks linger between calls, this could result
       
    16 in double execution of the callbacks. This can lead to unwanted
       
    17 behavior.
       
    18 
       
    19 The reproduce steps in the bug seem to only occur when the output of
       
    20 a command is less than the size of the current screen. This is not
       
    21 something that can easily be tested. I verified the test case works
       
    22 with this patch and that pager and color interaction continues to
       
    23 work. Since we have no existing automated tests for pager, this sadly
       
    24 appears to be the best testing I can do.
       
    25 
       
    26 diff --git a/mercurial/extensions.py b/mercurial/extensions.py
       
    27 --- a/mercurial/extensions.py
       
    28 +++ b/mercurial/extensions.py
       
    29 @@ -133,8 +133,12 @@ def loadall(ui):
       
    30  
       
    31          for fn in _aftercallbacks[shortname]:
       
    32              fn(loaded=False)
       
    33  
       
    34 +    # loadall() is called multiple times and lingering _aftercallbacks
       
    35 +    # entries could result in double execution. See issue4646.
       
    36 +    _aftercallbacks.clear()
       
    37 +
       
    38  def afterloaded(extension, callback):
       
    39      '''Run the specified function after a named extension is loaded.
       
    40  
       
    41      If the named extension is already loaded, the callback will be called
       
    42 _______________________________________________
       
    43 Mercurial-devel mailing list
       
    44 [email protected]
       
    45 http://selenic.com/mailman/listinfo/mercurial-devel