Mercurial > hg-stable
comparison hgext/automv.py @ 33190:54bc88c56ec8
configitems: register the 'automv.similarity' config
Default value has been ported.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 30 Jun 2017 03:27:24 +0200 |
parents | e4aefdb58ebe |
children | 38637dd39cfd |
comparison
equal
deleted
inserted
replaced
33189:2b233065f57a | 33190:54bc88c56ec8 |
---|---|
30 from mercurial import ( | 30 from mercurial import ( |
31 commands, | 31 commands, |
32 copies, | 32 copies, |
33 error, | 33 error, |
34 extensions, | 34 extensions, |
35 registrar, | |
35 scmutil, | 36 scmutil, |
36 similar | 37 similar |
38 ) | |
39 | |
40 configtable = {} | |
41 configitem = registrar.configitem(configtable) | |
42 | |
43 configitem('automv', 'similarity', | |
44 default=95, | |
37 ) | 45 ) |
38 | 46 |
39 def extsetup(ui): | 47 def extsetup(ui): |
40 entry = extensions.wrapcommand( | 48 entry = extensions.wrapcommand( |
41 commands.table, 'commit', mvcheck) | 49 commands.table, 'commit', mvcheck) |
46 def mvcheck(orig, ui, repo, *pats, **opts): | 54 def mvcheck(orig, ui, repo, *pats, **opts): |
47 """Hook to check for moves at commit time""" | 55 """Hook to check for moves at commit time""" |
48 renames = None | 56 renames = None |
49 disabled = opts.pop('no_automv', False) | 57 disabled = opts.pop('no_automv', False) |
50 if not disabled: | 58 if not disabled: |
51 threshold = ui.configint('automv', 'similarity', 95) | 59 threshold = ui.configint('automv', 'similarity') |
52 if not 0 <= threshold <= 100: | 60 if not 0 <= threshold <= 100: |
53 raise error.Abort(_('automv.similarity must be between 0 and 100')) | 61 raise error.Abort(_('automv.similarity must be between 0 and 100')) |
54 if threshold > 0: | 62 if threshold > 0: |
55 match = scmutil.match(repo[None], pats, opts) | 63 match = scmutil.match(repo[None], pats, opts) |
56 added, removed = _interestingfiles(repo, match) | 64 added, removed = _interestingfiles(repo, match) |