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

login
register
mail settings
Submitter phabricator
Date Aug. 2, 2018, 2:52 p.m.
Message ID <bd69db1f0c5a08a9f8078950fa4bc5a2@localhost.localdomain>
Download mbox | patch
Permalink /patch/33108/
State Not Applicable
Headers show

Comments

phabricator - Aug. 2, 2018, 2:52 p.m.
martinvonz updated this revision to Diff 9788.

REPOSITORY
  rHG Mercurial

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

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
@@ -1095,6 +1095,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) {
@@ -1795,7 +1801,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)
@@ -1854,7 +1860,7 @@ 
 				if (node == NULL)
 					return -1;
 
-				nt_insert(self, node, -1);
+				nt_delete_node(self, node);
 			}
 			if (self->added)
 				nt_invalidate_added(self, 0);
@@ -1907,7 +1913,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())