[PATCH 5 of 6 V2] osutil: add version to help detect breaking binary changes

Jun Wu quark at fb.com
Fri May 19 11:46:12 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1493167019 25200
#      Tue Apr 25 17:36:59 2017 -0700
# Node ID 358a98a28d54b4c7c193e4f631641243d7f55dc7
# Parent  1cf8daf6404e811cf222f8075edf38265d2bd4c9
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 358a98a28d54
osutil: add version to help detect breaking binary changes

See the previous patch for why.

diff --git a/mercurial/osutil.c b/mercurial/osutil.c
--- a/mercurial/osutil.c
+++ b/mercurial/osutil.c
@@ -1302,4 +1302,6 @@ static PyMethodDef methods[] = {
 };
 
+static const int version = 1;
+
 #ifdef IS_PY3K
 static struct PyModuleDef osutil_module = {
@@ -1313,16 +1315,21 @@ static struct PyModuleDef osutil_module 
 PyMODINIT_FUNC PyInit_osutil(void)
 {
+	PyObject *m;
 	if (PyType_Ready(&listdir_stat_type) < 0)
 		return NULL;
 
-	return PyModule_Create(&osutil_module);
+	m = PyModule_Create(&osutil_module);
+	PyModule_AddIntConstant(m, "version", version);
+	return m;
 }
 #else
 PyMODINIT_FUNC initosutil(void)
 {
+	PyObject *m;
 	if (PyType_Ready(&listdir_stat_type) == -1)
 		return;
 
-	Py_InitModule3("osutil", methods, osutil_doc);
+	m = Py_InitModule3("osutil", methods, osutil_doc);
+	PyModule_AddIntConstant(m, "version", version);
 }
 #endif


More information about the Mercurial-devel mailing list