# HG changeset patch # User Brendan Cully # Date 2006-10-11 19:06:14 # 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 --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -300,18 +300,19 @@ nomem: 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 @@ static PyObject *bdiff(PyObject *self, P 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 --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -973,7 +973,7 @@ class revlog(object): 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