# HG changeset patch # User Georges Racinet # Date 2024-01-17 13:39:06 # Node ID fe68a2dc0bf25bdd9628c774dacaf3d8efc4ac6a # Parent 187c5769a62974307e1ab0ff4129c23277e2957b chainsaw-update: log actual locks breaking Previously, the command would simply state that it was about to break locks, not if there was actually some to break. This version is race-free. It would be also possible to display the content of the lock before hand (not race-free but informative in almost all cases). diff --git a/hgext/chainsaw.py b/hgext/chainsaw.py --- a/hgext/chainsaw.py +++ b/hgext/chainsaw.py @@ -120,9 +120,10 @@ def update(ui, repo, **opts): raise error.InputError(_(b'specify a target revision with --rev')) if not source: raise error.InputError(_(b'specify a pull path with --source')) - ui.status(_(b'breaking locks, if any\n')) - repo.svfs.tryunlink(b'lock') - repo.vfs.tryunlink(b'wlock') + if repo.svfs.tryunlink(b'lock'): + 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() diff --git a/tests/test-chainsaw-update.t b/tests/test-chainsaw-update.t --- a/tests/test-chainsaw-update.t +++ b/tests/test-chainsaw-update.t @@ -26,7 +26,6 @@ Simple invocation $ hg init repo $ cd repo $ hg admin::chainsaw-update --rev default --source ../src - breaking locks, if any recovering after interrupted transaction, if any no interrupted transaction available pulling from ../src @@ -51,8 +50,15 @@ from the current hostname (happens a lot wlock: (.*?), process 171814, host invalid.host.test/effffffc \((\d+)s\) (re) [2] - $ hg admin::chainsaw-update --no-purge-ignored --rev default --source ../src -q + $ hg admin::chainsaw-update --no-purge-ignored --rev default --source ../src + had to break store lock + had to break working copy lock + recovering after interrupted transaction, if any no interrupted transaction available + pulling from ../src + updating to revision 'default' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + chainsaw-update to revision 'default' for repository at '$TESTTMP/repo' done Test file purging capabilities ------------------------------