54 ) |
54 ) |
55 |
55 |
56 |
56 |
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) |
|
60 renames = None |
59 renames = None |
61 disabled = opts.pop(b'no_automv', False) |
60 disabled = opts.pop('no_automv', False) |
62 with repo.wlock(): |
61 with repo.wlock(): |
63 if not disabled: |
62 if not disabled: |
64 threshold = ui.configint(b'automv', b'similarity') |
63 threshold = ui.configint(b'automv', b'similarity') |
65 if not 0 <= threshold <= 100: |
64 if not 0 <= threshold <= 100: |
66 raise error.Abort( |
65 raise error.Abort( |
67 _(b'automv.similarity must be between 0 and 100') |
66 _(b'automv.similarity must be between 0 and 100') |
68 ) |
67 ) |
69 if threshold > 0: |
68 if threshold > 0: |
70 match = scmutil.match(repo[None], pats, opts) |
69 match = scmutil.match( |
|
70 repo[None], pats, pycompat.byteskwargs(opts) |
|
71 ) |
71 added, removed = _interestingfiles(repo, match) |
72 added, removed = _interestingfiles(repo, match) |
72 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) |
73 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) |
73 renames = _findrenames( |
74 renames = _findrenames( |
74 repo, uipathfn, added, removed, threshold / 100.0 |
75 repo, uipathfn, added, removed, threshold / 100.0 |
75 ) |
76 ) |
80 # transaction. At the same time as we do the `addremove` logic |
81 # transaction. At the same time as we do the `addremove` logic |
81 # for commit. However we can't really do better with the |
82 # for commit. However we can't really do better with the |
82 # current extension structure, and this is not worse than what |
83 # current extension structure, and this is not worse than what |
83 # happened before. |
84 # happened before. |
84 scmutil._markchanges(repo, (), (), renames) |
85 scmutil._markchanges(repo, (), (), renames) |
85 return orig(ui, repo, *pats, **pycompat.strkwargs(opts)) |
86 return orig(ui, repo, *pats, **opts) |
86 |
87 |
87 |
88 |
88 def _interestingfiles(repo, matcher): |
89 def _interestingfiles(repo, matcher): |
89 """Find what files were added or removed in this commit. |
90 """Find what files were added or removed in this commit. |
90 |
91 |