Patchwork D4004: index: create function for deleting node from nodetree

login
register
mail settings
Submitter phabricator
Date Aug. 4, 2018, 3:41 a.m.
Message ID <52cb680d39b39a2387b699b37b9824da@localhost.localdomain>
Download mbox | patch
Permalink /patch/33210/
State Not Applicable
Headers show

Comments

phabricator - Aug. 4, 2018, 3:41 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf9fc59ea3135: index: create function for deleting node from nodetree (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4004?vs=9788&id=9879

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

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
@@ -1093,6 +1093,12 @@ 
 	return -1;
 }
 
+static int nt_delete_node(indexObject *self, const char *node)
+{
+	/* rev==-1 happens to get encoded as 0, which is interpreted as not set */
+	return nt_insert(self, node, -1);
+}
+
 static int nt_init(indexObject *self)
 {
 	if (self->nt == NULL) {
@@ -1792,7 +1798,7 @@ 
 		PyObject *tuple = PyList_GET_ITEM(self->added, i);
 		PyObject *node = PyTuple_GET_ITEM(tuple, 7);
 
-		nt_insert(self, PyBytes_AS_STRING(node), -1);
+		nt_delete_node(self, PyBytes_AS_STRING(node));
 	}
 
 	if (start == 0)
@@ -1851,7 +1857,7 @@ 
 				if (node == NULL)
 					return -1;
 
-				nt_insert(self, node, -1);
+				nt_delete_node(self, node);
 			}
 			if (self->added)
 				nt_invalidate_added(self, 0);
@@ -1903,7 +1909,7 @@ 
 		return -1;
 
 	if (value == NULL)
-		return self->nt ? nt_insert(self, node, -1) : 0;
+		return self->nt ? nt_delete_node(self, node) : 0;
 	rev = PyInt_AsLong(value);
 	if (rev > INT_MAX || rev < 0) {
 		if (!PyErr_Occurred())