Patchwork D4107: index: make "nt_*" functions work on an initialized nodetree

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2018, 1:13 p.m.
Message ID <25e17aeda5bb2dc4e5444fdcd37dbc6a@localhost.localdomain>
Download mbox | patch
Permalink /patch/33315/
State Not Applicable
Headers show

Comments

phabricator - Aug. 6, 2018, 1:13 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2aa4f06c1e91: index: make &quot;nt_*&quot; functions work on an initialized nodetree (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4107?vs=9910&id=9971

REVISION DETAIL
  https://phab.mercurial-scm.org/D4107

AFFECTED FILES
  mercurial/cext/revlog.c

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1240,11 +1240,6 @@ 
 static int nt_partialmatch(indexObject *self, const char *node,
 			   Py_ssize_t nodelen)
 {
-	if (nt_init(self) == -1)
-		return -3;
-	if (nt_populate(self) == -1)
-		return -3;
-
 	return nt_find(self, node, nodelen, 1);
 }
 
@@ -1261,11 +1256,6 @@ 
 {
 	int level, off;
 
-	if (nt_init(self) == -1)
-		return -3;
-	if (nt_populate(self) == -1)
-		return -3;
-
 	for (level = off = 0; level < 40; level++) {
 		int k, v;
 		nodetree *n = &self->nt[off];
@@ -1327,12 +1317,15 @@ 
 		Py_RETURN_NONE;
 	}
 
+	if (nt_init(self) == -1)
+		return NULL;
+	if (nt_populate(self) == -1)
+		return NULL;
 	rev = nt_partialmatch(self, node, nodelen);
 
 	switch (rev) {
 	case -4:
 		raise_revlog_error();
-	case -3:
 		return NULL;
 	case -2:
 		Py_RETURN_NONE;
@@ -1359,6 +1352,10 @@ 
 		return NULL;
 
 	self->ntlookups++;
+	if (nt_init(self) == -1)
+		return NULL;
+	if (nt_populate(self) == -1)
+		return NULL;
 	length = nt_shortest(self, node);
 	if (length == -3)
 		return NULL;