diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -266,7 +266,7 @@ return node; } -static int nt_insert(indexObject *self, const char *node, int rev); +static int nt_insert(nodetree *self, const char *node, int rev); static int node_check(PyObject *obj, char **node) { @@ -304,7 +304,7 @@ return NULL; if (self->nt) - nt_insert(self, node, len - 1); + nt_insert(self->nt, node, len - 1); Py_CLEAR(self->headrevs); Py_RETURN_NONE; @@ -978,7 +978,7 @@ * -2: not found * rest: valid rev */ -static int nt_find(indexObject *self, const char *node, Py_ssize_t nodelen, +static int nt_find(nodetree *self, const char *node, Py_ssize_t nodelen, int hex) { int (*getnybble)(const char *, Py_ssize_t) = hex ? hexdigit : nt_level; @@ -994,7 +994,7 @@ for (level = off = 0; level < maxlevel; level++) { int k = getnybble(node, level); - nodetreenode *n = &self->nt->nodes[off]; + nodetreenode *n = &self->nodes[off]; int v = n->children[k]; if (v < 0) { @@ -1002,7 +1002,7 @@ Py_ssize_t i; v = -(v + 2); - n = index_node(self, v); + n = index_node(self->index, v); if (n == NULL) return -2; for (i = level; i < maxlevel; i++) @@ -1039,7 +1039,7 @@ return self->length++; } -static int nt_insert(indexObject *self, const char *node, int rev) +static int nt_insert(nodetree *self, const char *node, int rev) { int level = 0; int off = 0; @@ -1049,7 +1049,7 @@ nodetreenode *n; int v; - n = &self->nt->nodes[off]; + n = &self->nodes[off]; v = n->children[k]; if (v == 0) { @@ -1057,7 +1057,7 @@ return 0; } if (v < 0) { - const char *oldnode = index_node_existing(self, -(v + 2)); + const char *oldnode = index_node_existing(self->index, -(v + 2)); int noff; if (oldnode == NULL) @@ -1066,17 +1066,17 @@ n->children[k] = -rev - 2; return 0; } - noff = nt_new(self->nt); + noff = nt_new(self); if (noff == -1) return -1; - /* self->nt->nodes may have been changed by realloc */ - self->nt->nodes[off].children[k] = noff; + /* self->nodes may have been changed by realloc */ + self->nodes[off].children[k] = noff; off = noff; - n = &self->nt->nodes[off]; + n = &self->nodes[off]; n->children[nt_level(oldnode, ++level)] = v; - if (level > self->nt->depth) - self->nt->depth = level; - self->nt->splits += 1; + if (level > self->depth) + self->depth = level; + self->splits += 1; } else { level += 1; off = v; @@ -1086,7 +1086,7 @@ return -1; } -static int nt_delete_node(indexObject *self, const char *node) +static int nt_delete_node(nodetree *self, const char *node) { /* rev==-2 happens to get encoded as 0, which is interpreted as not set */ return nt_insert(self, node, -2); @@ -1121,7 +1121,7 @@ self->nt->splits = 0; self->nt->length = 1; self->nt->index = self; - if (nt_insert(self, nullid, -1) == -1) { + if (nt_insert(self->nt, nullid, -1) == -1) { free(self->nt->nodes); free(self->nt); self->nt = NULL; @@ -1147,7 +1147,7 @@ return -3; self->ntlookups++; - rev = nt_find(self, node, nodelen, 0); + rev = nt_find(self->nt, node, nodelen, 0); if (rev >= -1) return rev; @@ -1166,7 +1166,7 @@ if (n == NULL) return -3; if (memcmp(node, n, nodelen > 20 ? 20 : nodelen) == 0) { - if (nt_insert(self, n, rev) == -1) + if (nt_insert(self->nt, n, rev) == -1) return -3; break; } @@ -1176,7 +1176,7 @@ const char *n = index_node_existing(self, rev); if (n == NULL) return -3; - if (nt_insert(self, n, rev) == -1) { + if (nt_insert(self->nt, n, rev) == -1) { self->ntrev = rev + 1; return -3; } @@ -1250,7 +1250,7 @@ const char *n = index_node_existing(self, rev); if (n == NULL) return -1; - if (nt_insert(self, n, rev) == -1) + if (nt_insert(self->nt, n, rev) == -1) return -1; } self->ntrev = -1; @@ -1258,7 +1258,7 @@ return 0; } -static int nt_partialmatch(indexObject *self, const char *node, +static int nt_partialmatch(nodetree *self, const char *node, Py_ssize_t nodelen) { return nt_find(self, node, nodelen, 1); @@ -1273,19 +1273,19 @@ * -2: not found (no exception set) * rest: length of shortest prefix */ -static int nt_shortest(indexObject *self, const char *node) +static int nt_shortest(nodetree *self, const char *node) { int level, off; for (level = off = 0; level < 40; level++) { int k, v; - nodetreenode *n = &self->nt->nodes[off]; + nodetreenode *n = &self->nodes[off]; k = nt_level(node, level); v = n->children[k]; if (v < 0) { const char *n; v = -(v + 2); - n = index_node_existing(self, v); + n = index_node_existing(self->index, v); if (n == NULL) return -3; if (memcmp(node, n, 20) != 0) @@ -1342,7 +1342,7 @@ return NULL; if (nt_populate(self) == -1) return NULL; - rev = nt_partialmatch(self, node, nodelen); + rev = nt_partialmatch(self->nt, node, nodelen); switch (rev) { case -4: @@ -1377,7 +1377,7 @@ return NULL; if (nt_populate(self) == -1) return NULL; - length = nt_shortest(self, node); + length = nt_shortest(self->nt, node); if (length == -3) return NULL; if (length == -2) { @@ -1799,7 +1799,7 @@ PyObject *tuple = PyList_GET_ITEM(self->added, i); PyObject *node = PyTuple_GET_ITEM(tuple, 7); - nt_delete_node(self, PyBytes_AS_STRING(node)); + nt_delete_node(self->nt, PyBytes_AS_STRING(node)); } if (start == 0) @@ -1858,7 +1858,7 @@ if (node == NULL) return -1; - nt_delete_node(self, node); + nt_delete_node(self->nt, node); } if (self->added) nt_invalidate_added(self, 0); @@ -1910,7 +1910,7 @@ return -1; if (value == NULL) - return self->nt ? nt_delete_node(self, node) : 0; + return self->nt ? nt_delete_node(self->nt, node) : 0; rev = PyInt_AsLong(value); if (rev > INT_MAX || rev < 0) { if (!PyErr_Occurred()) @@ -1920,7 +1920,7 @@ if (nt_init(self) == -1) return -1; - return nt_insert(self, node, (int)rev); + return nt_insert(self->nt, node, (int)rev); } /*