comparison hgext/automv.py @ 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 5cfc48354d0f
children 47af00b2217f
comparison
equal deleted inserted replaced
50123:4e95341c89aa 50124:18149ecb5122
57 def mvcheck(orig, ui, repo, *pats, **opts): 57 def mvcheck(orig, ui, repo, *pats, **opts):
58 """Hook to check for moves at commit time""" 58 """Hook to check for moves at commit time"""
59 opts = pycompat.byteskwargs(opts) 59 opts = pycompat.byteskwargs(opts)
60 renames = None 60 renames = None
61 disabled = opts.pop(b'no_automv', False) 61 disabled = opts.pop(b'no_automv', False)
62 if not disabled: 62 with repo.wlock():
63 threshold = ui.configint(b'automv', b'similarity') 63 if not disabled:
64 if not 0 <= threshold <= 100: 64 threshold = ui.configint(b'automv', b'similarity')
65 raise error.Abort(_(b'automv.similarity must be between 0 and 100')) 65 if not 0 <= threshold <= 100:
66 if threshold > 0: 66 raise error.Abort(
67 match = scmutil.match(repo[None], pats, opts) 67 _(b'automv.similarity must be between 0 and 100')
68 added, removed = _interestingfiles(repo, match) 68 )
69 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) 69 if threshold > 0:
70 renames = _findrenames( 70 match = scmutil.match(repo[None], pats, opts)
71 repo, uipathfn, added, removed, threshold / 100.0 71 added, removed = _interestingfiles(repo, match)
72 ) 72 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
73 renames = _findrenames(
74 repo, uipathfn, added, removed, threshold / 100.0
75 )
73 76
74 with repo.wlock():
75 if renames is not None: 77 if renames is not None:
76 with repo.dirstate.changing_files(repo): 78 with repo.dirstate.changing_files(repo):
77 # XXX this should be wider and integrated with the commit 79 # XXX this should be wider and integrated with the commit
78 # transaction. At the same time as we do the `addremove` logic 80 # transaction. At the same time as we do the `addremove` logic
79 # for commit. However we can't really do better with the 81 # for commit. However we can't really do better with the