Submitter | Boris Feld |
---|---|
Date | Dec. 15, 2018, 3:10 p.m. |
Message ID | <c1e47daaab82e7d9340b.1544886653@localhost.localdomain> |
Download | mbox | patch |
Permalink | /patch/37187/ |
State | Accepted |
Headers | show |
Comments
On Sat, 15 Dec 2018 15:10:53 +0000, Boris Feld wrote: > # HG changeset patch > # User Boris Feld <boris.feld@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` Queued, thanks. > +static const Py_ssize_t nullrev = -1; It's unclear whether nullrev should be int or ssize_t because our codebase is so inconsistent about the type of the revision numbers, but this is a good start.
Patch
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)