Patchwork D12481: debuglock: ignore ENOENT error when unlocking

login
register
mail settings
Submitter phabricator
Date April 6, 2022, 5:22 p.m.
Message ID <differential-rev-PHID-DREV-bqf5xvykcq6yltaxa2oe-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50827/
State New
Headers show

Comments

phabricator - April 6, 2022, 5:22 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is consistent with the main `lock.release` code.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D12481

AFFECTED FILES
  mercurial/debugcommands.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2148,9 +2148,17 @@ 
     """
 
     if opts.get('force_free_lock'):
-        repo.svfs.unlink(b'lock')
+        try:
+            repo.svfs.unlink(b'lock')
+        except (OSError, IOError) as e:
+            if e.errno != errno.ENOENT:
+                raise
     if opts.get('force_free_wlock'):
-        repo.vfs.unlink(b'wlock')
+        try:
+            repo.vfs.unlink(b'wlock')
+        except (OSError, IOError) as e:
+            if e.errno != errno.ENOENT:
+                raise
     if opts.get('force_free_lock') or opts.get('force_free_wlock'):
         return 0