[patch 1/3] Implement revlogng, a new index format for revlogs
Matt Mackall
mpm at selenic.com
Mon Mar 27 21:23:03 UTC 2006
On Mon, Mar 27, 2006 at 11:19:07AM -0500, Chris Mason wrote:
> On Monday 27 March 2006 03:26, Ollivier Robert wrote:
> > According to Chris Mason:
> > > # HG changeset patch
> > > # User mason at suse.com
> > > Implement revlogng, a new index format for revlogs
> >
> > It fails (to apply) with tip, could you have a look?
> >
>
> Matt, do you already have something merged locally? If not, I'll rediff.
Yeah, but my merge isn't passing tests.
BTW, here's some code to quickly calculate the size of patched
revisions during pull, rather than using -1. This will also let us
eliminate the "measure" heuristic.
diff -r 18a3e6369600 mercurial/mpatch.c
--- a/mercurial/mpatch.c Tue Mar 21 23:31:04 2006 -0800
+++ b/mercurial/mpatch.c Sun Mar 26 12:43:01 2006 -0600
@@ -354,8 +354,44 @@ cleanup:
return result;
}
+/* calculate size of a patched file directly */
+static PyObject *
+patchedsize(PyObject *self, PyObject *args)
+{
+ long orig, start, end, len, outlen = 0, last = 0;
+ int patchlen;
+ char *bin, *binend;
+ char decode[12]; /* for dealing with alignment issues */
+
+ if (!PyArg_ParseTuple(args, "ls#", &orig, &bin, &patchlen))
+ return NULL;
+
+ binend = bin + patchlen;
+
+ while (bin < binend) {
+ memcpy(decode, bin, 12);
+ start = ntohl(*(uint32_t *)decode);
+ end = ntohl(*(uint32_t *)(decode + 4));
+ len = ntohl(*(uint32_t *)(decode + 8));
+ bin += 12 + len;
+ outlen += start - last;
+ last = end;
+ outlen += len;
+ }
+
+ if (bin != binend) {
+ if (!PyErr_Occurred())
+ PyErr_SetString(mpatch_Error, "patch cannot be decoded");
+ return NULL;
+ }
+
+ outlen += orig - last;
+ return Py_BuildValue("l", outlen);
+}
+
static PyMethodDef methods[] = {
{"patches", patches, METH_VARARGS, "apply a series of patches\n"},
+ {"patchedsize", patchedsize, METH_VARARGS, "calculed patched size\n"},
{NULL, NULL}
};
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list