mercurial/cext/revlog.c
changeset 37904 a91f31a1e281
parent 37902 92ed344a9e64
child 37905 a9d9802d577e
equal deleted inserted replaced
37903:66dc9db6ed2c 37904:a91f31a1e281
   246 
   246 
   247 	data = index_deref(self, pos);
   247 	data = index_deref(self, pos);
   248 	return data ? data + 32 : NULL;
   248 	return data ? data + 32 : NULL;
   249 }
   249 }
   250 
   250 
       
   251 /*
       
   252  * Return the 20-byte SHA of the node corresponding to the given rev. The
       
   253  * rev is assumed to be existing. If not, an exception is set.
       
   254  */
       
   255 static const char *index_node_existing(indexObject *self, Py_ssize_t pos)
       
   256 {
       
   257 	const char *node = index_node(self, pos);
       
   258 	if (node == NULL) {
       
   259 		PyErr_Format(PyExc_IndexError, "could not access rev %d",
       
   260 		             (int)pos);
       
   261 	}
       
   262 	return node;
       
   263 }
       
   264 
   251 static int nt_insert(indexObject *self, const char *node, int rev);
   265 static int nt_insert(indexObject *self, const char *node, int rev);
   252 
   266 
   253 static int node_check(PyObject *obj, char **node, Py_ssize_t *nodelen)
   267 static int node_check(PyObject *obj, char **node, Py_ssize_t *nodelen)
   254 {
   268 {
   255 	if (PyBytes_AsStringAndSize(obj, node, nodelen) == -1)
   269 	if (PyBytes_AsStringAndSize(obj, node, nodelen) == -1)
  1280 		Py_RETURN_NONE;
  1294 		Py_RETURN_NONE;
  1281 	case -1:
  1295 	case -1:
  1282 		return PyBytes_FromStringAndSize(nullid, 20);
  1296 		return PyBytes_FromStringAndSize(nullid, 20);
  1283 	}
  1297 	}
  1284 
  1298 
  1285 	fullnode = index_node(self, rev);
  1299 	fullnode = index_node_existing(self, rev);
  1286 	if (fullnode == NULL) {
  1300 	if (fullnode == NULL) {
  1287 		PyErr_Format(PyExc_IndexError,
       
  1288 			     "could not access rev %d", rev);
       
  1289 		return NULL;
  1301 		return NULL;
  1290 	}
  1302 	}
  1291 	return PyBytes_FromStringAndSize(fullnode, 20);
  1303 	return PyBytes_FromStringAndSize(fullnode, 20);
  1292 }
  1304 }
  1293 
  1305