# HG changeset patch # User Pierre-Yves David # Date 2023-02-22 23:12:53 # Node ID a6ca61fd1fa82a4a21e6761f96fff6799660b63a # Parent c74d4ce646fba61f78f54905bb01c7936be06c73 narrow: widden the lock context in `tracking` The tracking configuration we modify must be read under lock. So we grab the lock sooner. diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -579,31 +579,31 @@ def trackedcmd(ui, repo, remotepath=None fm.end() return 0 - oldincludes, oldexcludes = repo.narrowpats + with repo.wlock(), repo.lock(): + oldincludes, oldexcludes = repo.narrowpats - # filter the user passed additions and deletions into actual additions and - # deletions of excludes and includes - addedincludes -= oldincludes - removedincludes &= oldincludes - addedexcludes -= oldexcludes - removedexcludes &= oldexcludes + # filter the user passed additions and deletions into actual additions and + # deletions of excludes and includes + addedincludes -= oldincludes + removedincludes &= oldincludes + addedexcludes -= oldexcludes + removedexcludes &= oldexcludes - widening = addedincludes or removedexcludes - narrowing = removedincludes or addedexcludes + widening = addedincludes or removedexcludes + narrowing = removedincludes or addedexcludes - if update_working_copy: - with repo.wlock(), repo.lock(), repo.transaction( - b'narrow-wc' - ), repo.dirstate.changing_parents(repo): - narrowspec.updateworkingcopy(repo) - narrowspec.copytoworkingcopy(repo) - return 0 + if update_working_copy: + with repo.transaction(b'narrow-wc'), repo.dirstate.changing_parents( + repo + ): + narrowspec.updateworkingcopy(repo) + narrowspec.copytoworkingcopy(repo) + return 0 - if not (widening or narrowing or autoremoveincludes): - ui.status(_(b"nothing to widen or narrow\n")) - return 0 + if not (widening or narrowing or autoremoveincludes): + ui.status(_(b"nothing to widen or narrow\n")) + return 0 - with repo.wlock(), repo.lock(): cmdutil.bailifchanged(repo) # Find the revisions we have in common with the remote. These will