Mercurial > public > mercurial-scm > hg
comparison mercurial/mdiff.py @ 515:03f27b1381f9
Whitespace cleanups
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Whitespace cleanups
manifest hash: ac954bc3a4f034c12638a259ecd65841f5b63c5c
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCwuubywK+sNU5EO8RAluIAJ98XQpNdZUpSmYKgDmrMRlbL76ZzQCfes0t
rknNUN/PhtyA4bzL646dOz4=
=UyCE
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Wed, 29 Jun 2005 10:42:35 -0800 |
parents | 3b9e3d3d2810 |
children | df8a5a0098d4 |
comparison
equal
deleted
inserted
replaced
514:874e577e332e | 515:03f27b1381f9 |
---|---|
45 | 45 |
46 def sortdiff(a, b): | 46 def sortdiff(a, b): |
47 la = lb = 0 | 47 la = lb = 0 |
48 lena = len(a) | 48 lena = len(a) |
49 lenb = len(b) | 49 lenb = len(b) |
50 | 50 |
51 while 1: | 51 while 1: |
52 am, bm, = la, lb | 52 am, bm, = la, lb |
53 | 53 |
54 # walk over matching lines | 54 # walk over matching lines |
55 while lb < lenb and la < lena and a[la] == b[lb] : | 55 while lb < lenb and la < lena and a[la] == b[lb] : |
63 while la < lena and lb < lenb and b[lb] < a[la]: | 63 while la < lena and lb < lenb and b[lb] < a[la]: |
64 lb += 1 | 64 lb += 1 |
65 | 65 |
66 if lb >= lenb: | 66 if lb >= lenb: |
67 break | 67 break |
68 | 68 |
69 # skip mismatched lines from a | 69 # skip mismatched lines from a |
70 while la < lena and lb < lenb and b[lb] > a[la]: | 70 while la < lena and lb < lenb and b[lb] > a[la]: |
71 la += 1 | 71 la += 1 |
72 | 72 |
73 if la >= lena: | 73 if la >= lena: |
74 break | 74 break |
75 | 75 |
76 yield (lena, lenb, 0) | 76 yield (lena, lenb, 0) |
77 | 77 |
78 def diff(a, b, sorted=0): | 78 def diff(a, b, sorted=0): |
79 if not a: | 79 if not a: |
80 s = "".join(b) | 80 s = "".join(b) |
98 s = "".join(b[lb:bm]) | 98 s = "".join(b[lb:bm]) |
99 if am > la or s: | 99 if am > la or s: |
100 bin.append(struct.pack(">lll", p[la], p[am], len(s)) + s) | 100 bin.append(struct.pack(">lll", p[la], p[am], len(s)) + s) |
101 la = am + size | 101 la = am + size |
102 lb = bm + size | 102 lb = bm + size |
103 | 103 |
104 return "".join(bin) | 104 return "".join(bin) |
105 | 105 |
106 def patchtext(bin): | 106 def patchtext(bin): |
107 pos = 0 | 107 pos = 0 |
108 t = [] | 108 t = [] |