comparison hgext/automv.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 2372284d9457
children 89a2afe31e82
comparison
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
40 40
41 configtable = {} 41 configtable = {}
42 configitem = registrar.configitem(configtable) 42 configitem = registrar.configitem(configtable)
43 43
44 configitem( 44 configitem(
45 'automv', 'similarity', default=95, 45 b'automv', b'similarity', default=95,
46 ) 46 )
47 47
48 48
49 def extsetup(ui): 49 def extsetup(ui):
50 entry = extensions.wrapcommand(commands.table, 'commit', mvcheck) 50 entry = extensions.wrapcommand(commands.table, b'commit', mvcheck)
51 entry[1].append( 51 entry[1].append(
52 ('', 'no-automv', None, _('disable automatic file move detection')) 52 (b'', b'no-automv', None, _(b'disable automatic file move detection'))
53 ) 53 )
54 54
55 55
56 def mvcheck(orig, ui, repo, *pats, **opts): 56 def mvcheck(orig, ui, repo, *pats, **opts):
57 """Hook to check for moves at commit time""" 57 """Hook to check for moves at commit time"""
58 opts = pycompat.byteskwargs(opts) 58 opts = pycompat.byteskwargs(opts)
59 renames = None 59 renames = None
60 disabled = opts.pop('no_automv', False) 60 disabled = opts.pop(b'no_automv', False)
61 if not disabled: 61 if not disabled:
62 threshold = ui.configint('automv', 'similarity') 62 threshold = ui.configint(b'automv', b'similarity')
63 if not 0 <= threshold <= 100: 63 if not 0 <= threshold <= 100:
64 raise error.Abort(_('automv.similarity must be between 0 and 100')) 64 raise error.Abort(_(b'automv.similarity must be between 0 and 100'))
65 if threshold > 0: 65 if threshold > 0:
66 match = scmutil.match(repo[None], pats, opts) 66 match = scmutil.match(repo[None], pats, opts)
67 added, removed = _interestingfiles(repo, match) 67 added, removed = _interestingfiles(repo, match)
68 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) 68 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
69 renames = _findrenames( 69 renames = _findrenames(
85 """ 85 """
86 stat = repo.status(match=matcher) 86 stat = repo.status(match=matcher)
87 added = stat.added 87 added = stat.added
88 removed = stat.removed 88 removed = stat.removed
89 89
90 copy = copies.pathcopies(repo['.'], repo[None], matcher) 90 copy = copies.pathcopies(repo[b'.'], repo[None], matcher)
91 # remove the copy files for which we already have copy info 91 # remove the copy files for which we already have copy info
92 added = [f for f in added if f not in copy] 92 added = [f for f in added if f not in copy]
93 93
94 return added, removed 94 return added, removed
95 95
106 for src, dst, score in similar.findrenames( 106 for src, dst, score in similar.findrenames(
107 repo, added, removed, similarity 107 repo, added, removed, similarity
108 ): 108 ):
109 if repo.ui.verbose: 109 if repo.ui.verbose:
110 repo.ui.status( 110 repo.ui.status(
111 _('detected move of %s as %s (%d%% similar)\n') 111 _(b'detected move of %s as %s (%d%% similar)\n')
112 % (uipathfn(src), uipathfn(dst), score * 100) 112 % (uipathfn(src), uipathfn(dst), score * 100)
113 ) 113 )
114 renames[dst] = src 114 renames[dst] = src
115 if renames: 115 if renames:
116 repo.ui.status(_('detected move of %d files\n') % len(renames)) 116 repo.ui.status(_(b'detected move of %d files\n') % len(renames))
117 return renames 117 return renames