# HG changeset patch # User Brendan Cully # Date 1160593574 25200 # Node ID 9061613c159381138fd2661f36fc5db09c4bc6a4 # Parent 534806df5b5a6128a839f0308de85a7366227667 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. diff -r 534806df5b5a -r 9061613c1593 mercurial/bdiff.c --- 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; diff -r 534806df5b5a -r 9061613c1593 mercurial/revlog.py --- a/mercurial/revlog.py Wed Oct 11 12:02:06 2006 -0700 +++ b/mercurial/revlog.py Wed Oct 11 12:06:14 2006 -0700 @@ -973,7 +973,7 @@ end = self.end(t) if not d: prev = self.revision(self.tip()) - d = self.diff(prev, str(text)) + d = self.diff(prev, text) data = compress(d) l = len(data[1]) + len(data[0]) dist = end - start + l