comparison hgext/automv.py @ 41660:f89aad980025

automv: respect ui.relative-paths Differential Revision: https://phab.mercurial-scm.org/D5910
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 08 Feb 2019 13:20:46 -0800
parents 38637dd39cfd
children abd902a85040
comparison
equal deleted inserted replaced
41659:ecf7f4ef52fb 41660:f89aad980025
62 if not 0 <= threshold <= 100: 62 if not 0 <= threshold <= 100:
63 raise error.Abort(_('automv.similarity must be between 0 and 100')) 63 raise error.Abort(_('automv.similarity must be between 0 and 100'))
64 if threshold > 0: 64 if threshold > 0:
65 match = scmutil.match(repo[None], pats, opts) 65 match = scmutil.match(repo[None], pats, opts)
66 added, removed = _interestingfiles(repo, match) 66 added, removed = _interestingfiles(repo, match)
67 renames = _findrenames(repo, match, added, removed, 67 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
68 renames = _findrenames(repo, uipathfn, added, removed,
68 threshold / 100.0) 69 threshold / 100.0)
69 70
70 with repo.wlock(): 71 with repo.wlock():
71 if renames is not None: 72 if renames is not None:
72 scmutil._markchanges(repo, (), (), renames) 73 scmutil._markchanges(repo, (), (), renames)
87 # remove the copy files for which we already have copy info 88 # remove the copy files for which we already have copy info
88 added = [f for f in added if f not in copy] 89 added = [f for f in added if f not in copy]
89 90
90 return added, removed 91 return added, removed
91 92
92 def _findrenames(repo, matcher, added, removed, similarity): 93 def _findrenames(repo, uipathfn, added, removed, similarity):
93 """Find what files in added are really moved files. 94 """Find what files in added are really moved files.
94 95
95 Any file named in removed that is at least similarity% similar to a file 96 Any file named in removed that is at least similarity% similar to a file
96 in added is seen as a rename. 97 in added is seen as a rename.
97 98
101 for src, dst, score in similar.findrenames( 102 for src, dst, score in similar.findrenames(
102 repo, added, removed, similarity): 103 repo, added, removed, similarity):
103 if repo.ui.verbose: 104 if repo.ui.verbose:
104 repo.ui.status( 105 repo.ui.status(
105 _('detected move of %s as %s (%d%% similar)\n') % ( 106 _('detected move of %s as %s (%d%% similar)\n') % (
106 matcher.rel(src), matcher.rel(dst), score * 100)) 107 uipathfn(src), uipathfn(dst), score * 100))
107 renames[dst] = src 108 renames[dst] = src
108 if renames: 109 if renames:
109 repo.ui.status(_('detected move of %d files\n') % len(renames)) 110 repo.ui.status(_('detected move of %d files\n') % len(renames))
110 return renames 111 return renames