Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGf89aad980025: automv: respect ui.relative-paths
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/automv.py (7 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Feb 8 2019, 4:20 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
disabled = opts.pop('no_automv', False) | disabled = opts.pop('no_automv', False) | ||||
if not disabled: | if not disabled: | ||||
threshold = ui.configint('automv', 'similarity') | threshold = ui.configint('automv', 'similarity') | ||||
if not 0 <= threshold <= 100: | if not 0 <= threshold <= 100: | ||||
raise error.Abort(_('automv.similarity must be between 0 and 100')) | raise error.Abort(_('automv.similarity must be between 0 and 100')) | ||||
if threshold > 0: | if threshold > 0: | ||||
match = scmutil.match(repo[None], pats, opts) | match = scmutil.match(repo[None], pats, opts) | ||||
added, removed = _interestingfiles(repo, match) | added, removed = _interestingfiles(repo, match) | ||||
renames = _findrenames(repo, match, added, removed, | uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) | ||||
renames = _findrenames(repo, uipathfn, added, removed, | |||||
threshold / 100.0) | threshold / 100.0) | ||||
with repo.wlock(): | with repo.wlock(): | ||||
if renames is not None: | if renames is not None: | ||||
scmutil._markchanges(repo, (), (), renames) | scmutil._markchanges(repo, (), (), renames) | ||||
return orig(ui, repo, *pats, **pycompat.strkwargs(opts)) | return orig(ui, repo, *pats, **pycompat.strkwargs(opts)) | ||||
def _interestingfiles(repo, matcher): | def _interestingfiles(repo, matcher): | ||||
"""Find what files were added or removed in this commit. | """Find what files were added or removed in this commit. | ||||
Returns a tuple of two lists: (added, removed). Only files not *already* | Returns a tuple of two lists: (added, removed). Only files not *already* | ||||
marked as moved are included in the added list. | marked as moved are included in the added list. | ||||
""" | """ | ||||
stat = repo.status(match=matcher) | stat = repo.status(match=matcher) | ||||
added = stat[1] | added = stat[1] | ||||
removed = stat[2] | removed = stat[2] | ||||
copy = copies._forwardcopies(repo['.'], repo[None], matcher) | copy = copies._forwardcopies(repo['.'], repo[None], matcher) | ||||
# remove the copy files for which we already have copy info | # remove the copy files for which we already have copy info | ||||
added = [f for f in added if f not in copy] | added = [f for f in added if f not in copy] | ||||
return added, removed | return added, removed | ||||
def _findrenames(repo, matcher, added, removed, similarity): | def _findrenames(repo, uipathfn, added, removed, similarity): | ||||
"""Find what files in added are really moved files. | """Find what files in added are really moved files. | ||||
Any file named in removed that is at least similarity% similar to a file | Any file named in removed that is at least similarity% similar to a file | ||||
in added is seen as a rename. | in added is seen as a rename. | ||||
""" | """ | ||||
renames = {} | renames = {} | ||||
if similarity > 0: | if similarity > 0: | ||||
for src, dst, score in similar.findrenames( | for src, dst, score in similar.findrenames( | ||||
repo, added, removed, similarity): | repo, added, removed, similarity): | ||||
if repo.ui.verbose: | if repo.ui.verbose: | ||||
repo.ui.status( | repo.ui.status( | ||||
_('detected move of %s as %s (%d%% similar)\n') % ( | _('detected move of %s as %s (%d%% similar)\n') % ( | ||||
matcher.rel(src), matcher.rel(dst), score * 100)) | uipathfn(src), uipathfn(dst), score * 100)) | ||||
renames[dst] = src | renames[dst] = src | ||||
if renames: | if renames: | ||||
repo.ui.status(_('detected move of %d files\n') % len(renames)) | repo.ui.status(_('detected move of %d files\n') % len(renames)) | ||||
return renames | return renames |