[PATCH 1 of 4 V2] revlog: introduce a constant for nullrev in `revlog.c`
Boris Feld
boris.feld at octobus.net
Sat Dec 15 15:10:53 UTC 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1544804562 -3600
# Fri Dec 14 17:22:42 2018 +0100
# Node ID c1e47daaab82e7d9340b0bd179d022fdd21062fc
# Parent 2f14d1bbc9a7a142b421285c0708320b46be7a56
# EXP-Topic sparse-followup
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c1e47daaab82
revlog: introduce a constant for nullrev in `revlog.c`
The value is important enough to be explicitly tracked.
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -97,6 +97,7 @@ static Py_ssize_t index_length(const ind
static PyObject *nullentry = NULL;
static const char nullid[20] = {0};
+static const Py_ssize_t nullrev = -1;
static Py_ssize_t inline_scan(indexObject *self, const char **offsets);
@@ -274,7 +275,7 @@ static PyObject *index_get(indexObject *
Py_ssize_t length = index_length(self);
PyObject *entry;
- if (pos == -1) {
+ if (pos == nullrev) {
Py_INCREF(nullentry);
return nullentry;
}
@@ -344,7 +345,7 @@ static const char *index_node(indexObjec
Py_ssize_t length = index_length(self);
const char *data;
- if (pos == -1)
+ if (pos == nullrev)
return nullid;
if (pos >= length)
@@ -667,7 +668,7 @@ static PyObject *reachableroots2(indexOb
}
/* Add its parents to the list of nodes to visit */
- if (revnum == -1)
+ if (revnum == nullrev)
continue;
r = index_get_parents(self, revnum, parents, (int)len - 1);
if (r < 0)
More information about the Mercurial-devel
mailing list