automv: lock the repository before searching for renames
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 21 Feb 2023 22:17:33 +0100
changeset 50124 18149ecb5122
parent 50123 4e95341c89aa
child 50125 eedbf8256263
automv: lock the repository before searching for renames I detected this while debugging something else.
hgext/automv.py
--- 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