# HG changeset patch # User mpm@selenic.com # Date 2005-06-22 19:30:14 # Node ID 08f00b6494f467b704df701c7e7240d5e6c3ce2f # Parent 79c6944622940764f12e813c80b88453382ace4b Replace difflib with bdiff for annotate -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Replace difflib with bdiff for annotate This is a quick hack to get bdiff working for annotate, can still be optimized quite a bit. manifest hash: 380ae3092c73b7e1946952edec3588248bc13c5e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCubxGywK+sNU5EO8RAv7RAJ9lTdxRAVqzGs4XnPoZAmx/fbeUZwCfWar2 RqLGipS5JmMOy1pL1ehNxqY= =KLgM -----END PGP SIGNATURE----- diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -10,7 +10,7 @@ import util from revlog import * from demandload import * demandload(globals(), "re lock urllib urllib2 transaction time socket") -demandload(globals(), "tempfile httprangereader difflib") +demandload(globals(), "tempfile httprangereader bdiff") def is_exec(f): return (os.stat(f).st_mode & 0100 != 0) @@ -66,16 +66,15 @@ class filelog(revlog): return [(rev, l) for l in text.splitlines(1)] def strip(annotation): - return [e[1] for e in annotation] + return "".join([e[1] for e in annotation]) def pair(parent, child): new = [] - sm = difflib.SequenceMatcher(None, strip(parent), strip(child)) - for o, m, n, s, t in sm.get_opcodes(): - if o == 'equal': - new += parent[m:n] - else: - new += child[s:t] + lb = 0 + for a1, a2, b1, b2 in bdiff.blocks(strip(parent), strip(child)): + new += child[lb:b1] + new += parent[a1:a2] + lb = b2 return new # find all ancestors