##// END OF EJS Templates
Teach bdiff to support buffer objects...
Brendan Cully -
r3335:9061613c default
parent child Browse files
Show More
@@ -300,18 +300,19 b' nomem:'
300
300
301 static PyObject *bdiff(PyObject *self, PyObject *args)
301 static PyObject *bdiff(PyObject *self, PyObject *args)
302 {
302 {
303 PyObject *sa, *sb, *result = NULL;
303 char *sa, *sb;
304 PyObject *result = NULL;
304 struct line *al, *bl;
305 struct line *al, *bl;
305 struct hunklist l = {NULL, NULL};
306 struct hunklist l = {NULL, NULL};
306 struct hunk *h;
307 struct hunk *h;
307 char encode[12], *rb;
308 char encode[12], *rb;
308 int an, bn, len = 0, la = 0, lb = 0;
309 int an, bn, len = 0, la, lb;
309
310
310 if (!PyArg_ParseTuple(args, "SS:bdiff", &sa, &sb))
311 if (!PyArg_ParseTuple(args, "t#t#:bdiff", &sa, &la, &sb, &lb))
311 return NULL;
312 return NULL;
312
313
313 an = splitlines(PyString_AsString(sa), PyString_Size(sa), &al);
314 an = splitlines(sa, la, &al);
314 bn = splitlines(PyString_AsString(sb), PyString_Size(sb), &bl);
315 bn = splitlines(sb, lb, &bl);
315 if (!al || !bl)
316 if (!al || !bl)
316 goto nomem;
317 goto nomem;
317
318
@@ -320,6 +321,7 b' static PyObject *bdiff(PyObject *self, P'
320 goto nomem;
321 goto nomem;
321
322
322 /* calculate length of output */
323 /* calculate length of output */
324 la = lb = 0;
323 for (h = l.base; h != l.head; h++) {
325 for (h = l.base; h != l.head; h++) {
324 if (h->a1 != la || h->b1 != lb)
326 if (h->a1 != la || h->b1 != lb)
325 len += 12 + bl[h->b1].l - bl[lb].l;
327 len += 12 + bl[h->b1].l - bl[lb].l;
@@ -973,7 +973,7 b' class revlog(object):'
973 end = self.end(t)
973 end = self.end(t)
974 if not d:
974 if not d:
975 prev = self.revision(self.tip())
975 prev = self.revision(self.tip())
976 d = self.diff(prev, str(text))
976 d = self.diff(prev, text)
977 data = compress(d)
977 data = compress(d)
978 l = len(data[1]) + len(data[0])
978 l = len(data[1]) + len(data[0])
979 dist = end - start + l
979 dist = end - start + l
General Comments 0
You need to be logged in to leave comments. Login now