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

login
register
mail settings
Submitter Jun Wu
Date May 19, 2017, 3:46 p.m.
Message ID <358a98a28d54b4c7c193.1495208772@x1c>
Download mbox | patch
Permalink /patch/20733/
State Accepted
Headers show

Comments

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

Patch

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