Mercurial > hg-stable
changeset 37905:a9d9802d577e
revlog: don't say "not found" on internal error
If index_node() returned NULL, then index_find_node() and and
nt_partialmatch() used to return -2 to signal that the node was not
found. However, we were passing in a revnum to index_node() that we
knew should exist, so the only reason it could return NULL was due to
some internal error or perhaps out of memory. Let's not use "not
found" for these cases. I suppose we never noticed this because these
error never happen in practice.
I think there are more places where we should error out instead of
reporting that the node was not found, but the cases mentioned above
were all I cared about right now (because using the same error code
for all failures simplified some future patches).
Differential Revision: https://phab.mercurial-scm.org/D3457
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 04 May 2018 22:04:44 -0700 |
parents | a91f31a1e281 |
children | 858c7bfb3f49 |
files | mercurial/cext/revlog.c |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cext/revlog.c Fri May 04 21:58:43 2018 -0700 +++ b/mercurial/cext/revlog.c Fri May 04 22:04:44 2018 -0700 @@ -1151,9 +1151,9 @@ */ if (self->ntmisses++ < 4) { for (rev = self->ntrev - 1; rev >= 0; rev--) { - const char *n = index_node(self, rev); + const char *n = index_node_existing(self, rev); if (n == NULL) - return -2; + return -3; if (memcmp(node, n, nodelen > 20 ? 20 : nodelen) == 0) { if (nt_insert(self, n, rev) == -1) return -3; @@ -1162,11 +1162,9 @@ } } else { for (rev = self->ntrev - 1; rev >= 0; rev--) { - const char *n = index_node(self, rev); - if (n == NULL) { - self->ntrev = rev + 1; - return -2; - } + const char *n = index_node_existing(self, rev); + if (n == NULL) + return -3; if (nt_insert(self, n, rev) == -1) { self->ntrev = rev + 1; return -3; @@ -1243,9 +1241,9 @@ if (self->ntrev > 0) { /* ensure that the radix tree is fully populated */ for (rev = self->ntrev - 1; rev >= 0; rev--) { - const char *n = index_node(self, rev); + const char *n = index_node_existing(self, rev); if (n == NULL) - return -2; + return -3; if (nt_insert(self, n, rev) == -1) return -3; }