changeset 50124:18149ecb5122

automv: lock the repository before searching for renames I detected this while debugging something else.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 21 Feb 2023 22:17:33 +0100
parents 4e95341c89aa
children eedbf8256263
files hgext/automv.py
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/automv.py	Mon Feb 20 23:46:20 2023 +0100
+++ b/hgext/automv.py	Tue Feb 21 22:17:33 2023 +0100
@@ -59,19 +59,21 @@
     opts = pycompat.byteskwargs(opts)
     renames = None
     disabled = opts.pop(b'no_automv', False)
-    if not disabled:
-        threshold = ui.configint(b'automv', b'similarity')
-        if not 0 <= threshold <= 100:
-            raise error.Abort(_(b'automv.similarity must be between 0 and 100'))
-        if threshold > 0:
-            match = scmutil.match(repo[None], pats, opts)
-            added, removed = _interestingfiles(repo, match)
-            uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
-            renames = _findrenames(
-                repo, uipathfn, added, removed, threshold / 100.0
-            )
+    with repo.wlock():
+        if not disabled:
+            threshold = ui.configint(b'automv', b'similarity')
+            if not 0 <= threshold <= 100:
+                raise error.Abort(
+                    _(b'automv.similarity must be between 0 and 100')
+                )
+            if threshold > 0:
+                match = scmutil.match(repo[None], pats, opts)
+                added, removed = _interestingfiles(repo, match)
+                uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
+                renames = _findrenames(
+                    repo, uipathfn, added, removed, threshold / 100.0
+                )
 
-    with repo.wlock():
         if renames is not None:
             with repo.dirstate.changing_files(repo):
                 # XXX this should be wider and integrated with the commit