31 ('', 'no-automv', None, |
31 ('', 'no-automv', None, |
32 _('disable automatic file move detection'))) |
32 _('disable automatic file move detection'))) |
33 |
33 |
34 def mvcheck(orig, ui, repo, *pats, **opts): |
34 def mvcheck(orig, ui, repo, *pats, **opts): |
35 """Hook to check for moves at commit time""" |
35 """Hook to check for moves at commit time""" |
|
36 renames = None |
36 disabled = opts.pop('no_automv', False) |
37 disabled = opts.pop('no_automv', False) |
37 if not disabled: |
38 if not disabled: |
38 threshold = float(ui.config('automv', 'similarity', '1.00')) |
39 threshold = float(ui.config('automv', 'similarity', '1.00')) |
39 if threshold > 0: |
40 if threshold > 0: |
40 match = scmutil.match(repo[None], pats, opts) |
41 match = scmutil.match(repo[None], pats, opts) |
41 added, removed = _interestingfiles(repo, match) |
42 added, removed = _interestingfiles(repo, match) |
42 renames = _findrenames(repo, match, added, removed, threshold) |
43 renames = _findrenames(repo, match, added, removed, threshold) |
|
44 |
|
45 with repo.wlock(): |
|
46 if renames is not None: |
43 scmutil._markchanges(repo, (), (), renames) |
47 scmutil._markchanges(repo, (), (), renames) |
44 |
48 return orig(ui, repo, *pats, **opts) |
45 return orig(ui, repo, *pats, **opts) |
|
46 |
49 |
47 def _interestingfiles(repo, matcher): |
50 def _interestingfiles(repo, matcher): |
48 """Find what files were added or removed in this commit. |
51 """Find what files were added or removed in this commit. |
49 |
52 |
50 Returns a tuple of two lists: (added, removed). Only files not *already* |
53 Returns a tuple of two lists: (added, removed). Only files not *already* |