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

login
register
mail settings
Submitter Jun Wu
Date May 3, 2017, 12:20 a.m.
Message ID <e28f172d90de2ba42b9a.1493770800@x1c>
Download mbox | patch
Permalink /patch/20375/
State Deferred
Headers show

Comments

Jun Wu - May 3, 2017, 12:20 a.m.
# HG changeset patch
# User Jun Wu <quark@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

Patch

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