# HG changeset patch # User mpm@selenic.com # Date 1119468614 28800 # 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 -r 79c694462294 -r 08f00b6494f4 mercurial/hg.py --- a/mercurial/hg.py Wed Jun 22 11:27:50 2005 -0800 +++ b/mercurial/hg.py Wed Jun 22 11:30:14 2005 -0800 @@ -10,7 +10,7 @@ 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 @@ 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