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).
--- a/hgext/chainsaw.py Wed Jan 17 14:26:58 2024 +0100
+++ b/hgext/chainsaw.py Wed Jan 17 14:39:06 2024 +0100
@@ -120,9 +120,10 @@
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()
--- a/tests/test-chainsaw-update.t Wed Jan 17 14:26:58 2024 +0100
+++ b/tests/test-chainsaw-update.t Wed Jan 17 14:39:06 2024 +0100
@@ -26,7 +26,6 @@
$ 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 @@
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
------------------------------