[PATCH 4 of 8 V3] revlog: add a native implementation of issnapshot
Boris Feld
boris.feld at octobus.net
Fri Dec 28 13:12: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 1ab85bafd017062237be01429bc3ce48ee3ef796
# Parent a85d334d94953fa99f96055baf20f1f0d946b172
# EXP-Topic sparse-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1ab85bafd017
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,39 @@ static inline int index_baserev(indexObj
return result;
}
+/**
+ * Find if a revision is a snapshot or not
+ *
+ * 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