[PATCH 3 of 8] diffhelpers: add _version to help detect breaking binary changes

Jun Wu quark at fb.com
Tue May 2 20:20:00 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1493167213 25200
#      Tue Apr 25 17:40:13 2017 -0700
# Node ID e28f172d90de2ba42b9a3961b99160cedb44e91b
# Parent  28d82d6b0db973570d25d1082a9977ed1bb695de
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r e28f172d90de
diffhelpers: add _version to help detect breaking binary changes

diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c
--- a/mercurial/diffhelpers.c
+++ b/mercurial/diffhelpers.c
@@ -165,4 +165,8 @@ static PyMethodDef methods[] = {
 };
 
+/* Binary version. When breaking changes are made, bump this number and change
+ * __init__.py, so the module loader can notice and fallback to pure. */
+static const int _version = 1;
+
 #ifdef IS_PY3K
 static struct PyModuleDef diffhelpers_module = {
@@ -186,4 +190,5 @@ PyMODINIT_FUNC PyInit_diffhelpers(void)
 	Py_INCREF(diffhelpers_Error);
 	PyModule_AddObject(m, "diffhelpersError", diffhelpers_Error);
+	PyModule_AddIntConstant(m, "_version", _version);
 
 	return m;
@@ -193,7 +198,9 @@ PyMODINIT_FUNC
 initdiffhelpers(void)
 {
-	Py_InitModule3("diffhelpers", methods, diffhelpers_doc);
+	PyObject *m;
+	m = Py_InitModule3("diffhelpers", methods, diffhelpers_doc);
 	diffhelpers_Error = PyErr_NewException("diffhelpers.diffhelpersError",
 	                                        NULL, NULL);
+	PyModule_AddIntConstant(m, "_version", _version);
 }
 #endif


More information about the Mercurial-devel mailing list