Mercurial > hg
changeset 10608:87fce8c5e29d
addremove: avoid fetching data again and again
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Mon, 08 Mar 2010 00:01:12 +0100 |
parents | f3ac9d6105ee |
children | 5ee3faa7c563 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Mar 08 00:00:03 2010 +0100 +++ b/mercurial/cmdutil.py Mon Mar 08 00:01:12 2010 +0100 @@ -295,6 +295,12 @@ continue fctx = ctx.filectx(r) + # lazily load text + @util.cachefunc + def data(): + orig = fctx.data() + return orig, mdiff.splitnewlines(orig) + def score(text): if not len(text): return 0.0 @@ -302,14 +308,13 @@ return 1.0 if threshold == 1.0: return 0.0 - orig = fctx.data() + orig, lines = data() # bdiff.blocks() returns blocks of matching lines # count the number of bytes in each equal = 0 - alines = mdiff.splitnewlines(text) matches = bdiff.blocks(text, orig) for x1, x2, y1, y2 in matches: - for line in alines[x1:x2]: + for line in lines[y1:y2]: equal += len(line) lengths = len(text) + len(orig)