[PATCH 4 of 8] mpatch: add _version to help detect breaking binary changes

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


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1493167116 25200
#      Tue Apr 25 17:38:36 2017 -0700
# Node ID 3ee58fc62a7de71b2bb3767d1a20c7e51d51cb04
# Parent  e28f172d90de2ba42b9a3961b99160cedb44e91b
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 3ee58fc62a7d
mpatch: add _version to help detect breaking binary changes

diff --git a/mercurial/mpatch_module.c b/mercurial/mpatch_module.c
--- a/mercurial/mpatch_module.c
+++ b/mercurial/mpatch_module.c
@@ -161,4 +161,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 mpatch_module = {
@@ -182,4 +186,5 @@ PyMODINIT_FUNC PyInit_mpatch(void)
 	Py_INCREF(mpatch_Error);
 	PyModule_AddObject(m, "mpatchError", mpatch_Error);
+	PyModule_AddIntConstant(m, "_version", _version);
 
 	return m;
@@ -189,7 +194,9 @@ PyMODINIT_FUNC
 initmpatch(void)
 {
-	Py_InitModule3("mpatch", methods, mpatch_doc);
+	PyObject *m;
+	m = Py_InitModule3("mpatch", methods, mpatch_doc);
 	mpatch_Error = PyErr_NewException("mercurial.mpatch.mpatchError",
 					  NULL, NULL);
+	PyModule_AddIntConstant(m, "_version", _version);
 }
 #endif


More information about the Mercurial-devel mailing list