Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bdiff.c @ 3335:9061613c1593
Teach bdiff to support buffer objects
manifest.add gives revlog.addrevision a buffer object, which may
be cached and used for a second call in the same session (as mq does
when pushing multiple patches). The other option would be to cast the
buffer to str when caching it.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Wed, 11 Oct 2006 12:06:14 -0700 |
parents | 345bac2bc4ec |
children | 4bad632913d8 |
line wrap: on
line diff
--- a/mercurial/bdiff.c Wed Oct 11 12:02:06 2006 -0700 +++ b/mercurial/bdiff.c Wed Oct 11 12:06:14 2006 -0700 @@ -300,18 +300,19 @@ static PyObject *bdiff(PyObject *self, PyObject *args) { - PyObject *sa, *sb, *result = NULL; + char *sa, *sb; + PyObject *result = NULL; struct line *al, *bl; struct hunklist l = {NULL, NULL}; struct hunk *h; char encode[12], *rb; - int an, bn, len = 0, la = 0, lb = 0; + int an, bn, len = 0, la, lb; - if (!PyArg_ParseTuple(args, "SS:bdiff", &sa, &sb)) + if (!PyArg_ParseTuple(args, "t#t#:bdiff", &sa, &la, &sb, &lb)) return NULL; - an = splitlines(PyString_AsString(sa), PyString_Size(sa), &al); - bn = splitlines(PyString_AsString(sb), PyString_Size(sb), &bl); + an = splitlines(sa, la, &al); + bn = splitlines(sb, lb, &bl); if (!al || !bl) goto nomem; @@ -320,6 +321,7 @@ goto nomem; /* calculate length of output */ + la = lb = 0; for (h = l.base; h != l.head; h++) { if (h->a1 != la || h->b1 != lb) len += 12 + bl[h->b1].l - bl[lb].l;