# HG changeset patch # User Pierre-Yves David # Date 1708655555 -3600 # Node ID dd519ea71416d188d933e9f91a642486f6961c05 # Parent d36a81d70f258c53a4b8783624cd0ddf46c2cf8a chainsaw-update: lock the repository for the duration of the operation This should prevent and catch some misusage where something else try to touch the repository. diff -r d36a81d70f25 -r dd519ea71416 hgext/chainsaw.py --- a/hgext/chainsaw.py Fri Feb 23 11:41:55 2024 +0100 +++ b/hgext/chainsaw.py Fri Feb 23 03:32:35 2024 +0100 @@ -180,38 +180,40 @@ ui.status(_(b'had to break store lock\n')) if repo.vfs.tryunlink(b'wlock'): ui.status(_(b'had to break working copy lock\n')) - - ui.status(_(b'recovering after interrupted transaction, if any\n')) - repo.recover() + # If another process relock after the breacking above, the next locking + # will have to wait. + with repo.wlock(), repo.lock(): + ui.status(_(b'recovering after interrupted transaction, if any\n')) + repo.recover() - ui.status(_(b'pulling from %s\n') % source) - if repo_created and not opts.get('initial_clone_minimal'): - pull_revs = [] - else: - pull_revs = [rev] - overrides = {(b'ui', b'quiet'): True} - with repo.ui.configoverride(overrides, b'chainsaw-update'): - pull = cmdutil.findcmd(b'pull', commands.table)[1][0] - pull(repo.ui, repo, source, rev=pull_revs, remote_hidden=False) + ui.status(_(b'pulling from %s\n') % source) + if repo_created and not opts.get('initial_clone_minimal'): + pull_revs = [] + else: + pull_revs = [rev] + overrides = {(b'ui', b'quiet'): True} + with repo.ui.configoverride(overrides, b'chainsaw-update'): + pull = cmdutil.findcmd(b'pull', commands.table)[1][0] + pull(repo.ui, repo, source, rev=pull_revs, remote_hidden=False) - purge = cmdutil.findcmd(b'purge', commands.table)[1][0] - purge( - ui, - repo, - dirs=True, - all=opts.get('purge_ignored'), - files=opts.get('purge_unknown'), - confirm=False, - ) + purge = cmdutil.findcmd(b'purge', commands.table)[1][0] + purge( + ui, + repo, + dirs=True, + all=opts.get('purge_ignored'), + files=opts.get('purge_unknown'), + confirm=False, + ) - ui.status(_(b'updating to revision \'%s\'\n') % rev) - update = cmdutil.findcmd(b'update', commands.table)[1][0] - update(ui, repo, rev=rev, clean=True) + ui.status(_(b'updating to revision \'%s\'\n') % rev) + update = cmdutil.findcmd(b'update', commands.table)[1][0] + update(ui, repo, rev=rev, clean=True) - ui.status( - _( - b'chainsaw-update to revision \'%s\' ' - b'for repository at \'%s\' done\n' + ui.status( + _( + b'chainsaw-update to revision \'%s\' ' + b'for repository at \'%s\' done\n' + ) + % (rev, repo.root) ) - % (rev, repo.root) - )