Show More
@@ -13,7 +13,6 b' from .i18n import _' | |||
|
13 | 13 | from . import ( |
|
14 | 14 | bdiff, |
|
15 | 15 | mdiff, |
|
16 | util, | |
|
17 | 16 | ) |
|
18 | 17 | |
|
19 | 18 | def _findexactmatches(repo, added, removed): |
@@ -43,16 +42,14 b' def _findexactmatches(repo, added, remov' | |||
|
43 | 42 | # Done |
|
44 | 43 | repo.ui.progress(_('searching for exact renames'), None) |
|
45 | 44 | |
|
46 | @util.cachefunc | |
|
47 | 45 | def _ctxdata(fctx): |
|
48 | 46 | # lazily load text |
|
49 | 47 | orig = fctx.data() |
|
50 | 48 | return orig, mdiff.splitnewlines(orig) |
|
51 | 49 | |
|
52 | @util.cachefunc | |
|
53 | def score(fctx1, fctx2): | |
|
54 |
text = fctx |
|
|
55 | orig, lines = _ctxdata(fctx2) | |
|
50 | def _score(fctx, otherdata): | |
|
51 | orig, lines = otherdata | |
|
52 | text = fctx.data() | |
|
56 | 53 | # bdiff.blocks() returns blocks of matching lines |
|
57 | 54 | # count the number of bytes in each |
|
58 | 55 | equal = 0 |
@@ -64,6 +61,9 b' def score(fctx1, fctx2):' | |||
|
64 | 61 | lengths = len(text) + len(orig) |
|
65 | 62 | return equal * 2.0 / lengths |
|
66 | 63 | |
|
64 | def score(fctx1, fctx2): | |
|
65 | return _score(fctx1, _ctxdata(fctx2)) | |
|
66 | ||
|
67 | 67 | def _findsimilarmatches(repo, added, removed, threshold): |
|
68 | 68 | '''find potentially renamed files based on similar file content |
|
69 | 69 | |
@@ -75,9 +75,12 b' def _findsimilarmatches(repo, added, rem' | |||
|
75 | 75 | repo.ui.progress(_('searching for similar files'), i, |
|
76 | 76 | total=len(removed), unit=_('files')) |
|
77 | 77 | |
|
78 | data = None | |
|
78 | 79 | for a in added: |
|
79 | 80 | bestscore = copies.get(a, (None, threshold))[1] |
|
80 | myscore = score(a, r) | |
|
81 | if data is None: | |
|
82 | data = _ctxdata(r) | |
|
83 | myscore = _score(a, data) | |
|
81 | 84 | if myscore >= bestscore: |
|
82 | 85 | copies[a] = (r, myscore) |
|
83 | 86 | repo.ui.progress(_('searching'), None) |
General Comments 0
You need to be logged in to leave comments.
Login now