[PATCH 3 of 7 V4] revlog: add a native implementation of issnapshot
Boris Feld
boris.feld at octobus.net
Sun Dec 30 13:43:50 EST 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1545040633 -3600
# Mon Dec 17 10:57:13 2018 +0100
# Node ID 1317aebed1c5e98e3a89efe807f46d013a84e270
# Parent 260f93686b0c2b151b94f87881496f5228220ae3
# EXP-Topic sparse-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1317aebed1c5
revlog: add a native implementation of issnapshot
This will be used in the next changesets
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -995,6 +995,40 @@ static inline int index_baserev(indexObj
return result;
}
+/**
+ * Find if a revision is a snapshot or not
+ *
+ * Only relevant for sparse-revlog case.
+ * Callers must ensure that rev is in a valid range.
+ */
+static int index_issnapshotrev(indexObject *self, Py_ssize_t rev)
+{
+ int ps[2];
+ Py_ssize_t base;
+ while (rev >= 0) {
+ base = (Py_ssize_t)index_baserev(self, rev);
+ if (base == rev) {
+ base = -1;
+ }
+ if (base == -2) {
+ assert(PyErr_Occurred());
+ return -1;
+ }
+ if (base == -1) {
+ return 1;
+ }
+ if (index_get_parents(self, rev, ps, (int)rev) < 0) {
+ assert(PyErr_Occurred());
+ return -1;
+ };
+ if (base == ps[0] || base == ps[1]) {
+ return 0;
+ }
+ rev = base;
+ }
+ return rev == -1;
+}
+
static PyObject *index_deltachain(indexObject *self, PyObject *args)
{
int rev, generaldelta;
More information about the Mercurial-devel
mailing list