Mercurial > hg-stable
comparison hgext/automv.py @ 28149:d356d5250ab2
automv: improve function docstrings
author | Martijn Pieters <mjpieters@fb.com> |
---|---|
date | Mon, 15 Feb 2016 17:01:33 +0000 |
parents | e8c2a60864fc |
children | 7a984cece04a |
comparison
equal
deleted
inserted
replaced
28148:e8c2a60864fc | 28149:d356d5250ab2 |
---|---|
30 entry[1].append( | 30 entry[1].append( |
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 disabled = opts.pop('no_automv', False) | 36 disabled = opts.pop('no_automv', False) |
36 if not disabled: | 37 if not disabled: |
37 threshold = float(ui.config('automv', 'similarity', '1.00')) | 38 threshold = float(ui.config('automv', 'similarity', '1.00')) |
38 if threshold > 0: | 39 if threshold > 0: |
39 match = scmutil.match(repo[None], pats, opts) | 40 match = scmutil.match(repo[None], pats, opts) |
42 _markchanges(repo, renames) | 43 _markchanges(repo, renames) |
43 | 44 |
44 return orig(ui, repo, *pats, **opts) | 45 return orig(ui, repo, *pats, **opts) |
45 | 46 |
46 def _interestingfiles(repo, matcher): | 47 def _interestingfiles(repo, matcher): |
48 """Find what files were added or removed in this commit. | |
49 | |
50 Returns a tuple of two lists: (added, removed). Only files not *already* | |
51 marked as moved are included in the added list. | |
52 | |
53 """ | |
47 stat = repo.status(match=matcher) | 54 stat = repo.status(match=matcher) |
48 added = stat[1] | 55 added = stat[1] |
49 removed = stat[2] | 56 removed = stat[2] |
50 | 57 |
51 copy = copies._forwardcopies(repo['.'], repo[None], matcher) | 58 copy = copies._forwardcopies(repo['.'], repo[None], matcher) |
53 added = [f for f in added if f not in copy] | 60 added = [f for f in added if f not in copy] |
54 | 61 |
55 return added, removed | 62 return added, removed |
56 | 63 |
57 def _findrenames(repo, matcher, added, removed, similarity): | 64 def _findrenames(repo, matcher, added, removed, similarity): |
58 """Find renames from removed files of the current commit/amend files | 65 """Find what files in added are really moved files. |
59 to the added ones""" | 66 |
67 Any file named in removed that is at least similarity% similar to a file | |
68 in added is seen as a rename. | |
69 | |
70 """ | |
60 renames = {} | 71 renames = {} |
61 if similarity > 0: | 72 if similarity > 0: |
62 for src, dst, score in similar.findrenames( | 73 for src, dst, score in similar.findrenames( |
63 repo, added, removed, similarity): | 74 repo, added, removed, similarity): |
64 if repo.ui.verbose: | 75 if repo.ui.verbose: |