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-----
--- 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