Quantcast

[PATCH 1 of 6 V2] bdiff: add version to help detect breaking binary changes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 1 of 6 V2] bdiff: add version to help detect breaking binary changes

Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# Date 1493166881 25200
#      Tue Apr 25 17:34:41 2017 -0700
# Node ID 90ad5352d3c20b5f463d814b46cef15512edbacb
# Parent  763d7292569138886c3fdf179f7e688351bfb212
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 90ad5352d3c2
bdiff: add version to help detect breaking binary changes

Previously, we have no way to detect if a compiled .so file could be used or
not, and blindly load it if it exists. Usually we carefully maintain
compatibility of .so and fallback to pure code gracefully. But if we stick
to the rules, certain nice changes will be impossible to make in a clean
way.

This patch adds a "version" constant to the module so we can detect
inconsistency and take appropriate actions (warn, abort, fallback to pure,
run make automatically) in module loader.

diff --git a/mercurial/bdiff_module.c b/mercurial/bdiff_module.c
--- a/mercurial/bdiff_module.c
+++ b/mercurial/bdiff_module.c
@@ -193,4 +193,6 @@ static PyMethodDef methods[] = {
 };
 
+static const int version = 1;
+
 #ifdef IS_PY3K
 static struct PyModuleDef bdiff_module = {
@@ -204,10 +206,15 @@ static struct PyModuleDef bdiff_module =
 PyMODINIT_FUNC PyInit_bdiff(void)
 {
- return PyModule_Create(&bdiff_module);
+ PyObject *m;
+ m = PyModule_Create(&bdiff_module);
+ PyModule_AddIntConstant(m, "version", version);
+ return m;
 }
 #else
 PyMODINIT_FUNC initbdiff(void)
 {
- Py_InitModule3("bdiff", methods, mdiff_doc);
+ PyObject *m;
+ m = Py_InitModule3("bdiff", methods, mdiff_doc);
+ PyModule_AddIntConstant(m, "version", version);
 }
 #endif
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 2 of 6 V2] base85: add version to help detect breaking binary changes

Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# Date 1493167548 25200
#      Tue Apr 25 17:45:48 2017 -0700
# Node ID bd01a5b895000ea8791540098b38ae78bed15a2f
# Parent  90ad5352d3c20b5f463d814b46cef15512edbacb
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r bd01a5b89500
base85: add version to help detect breaking binary changes

diff --git a/mercurial/base85.c b/mercurial/base85.c
--- a/mercurial/base85.c
+++ b/mercurial/base85.c
@@ -158,4 +158,6 @@ static PyMethodDef methods[] = {
 };
 
+static const int version = 1;
+
 #ifdef IS_PY3K
 static struct PyModuleDef base85_module = {
@@ -169,14 +171,18 @@ static struct PyModuleDef base85_module
 PyMODINIT_FUNC PyInit_base85(void)
 {
+ PyObject *m;
  b85prep();
 
- return PyModule_Create(&base85_module);
+ m = PyModule_Create(&base85_module);
+ PyModule_AddIntConstant(m, "version", version);
 }
 #else
 PyMODINIT_FUNC initbase85(void)
 {
- Py_InitModule3("base85", methods, base85_doc);
+ PyObject *m;
+ m = Py_InitModule3("base85", methods, base85_doc);
 
  b85prep();
+ PyModule_AddIntConstant(m, "version", version);
 }
 #endif
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 3 of 6 V2] diffhelpers: add version to help detect breaking binary changes

Jun Wu
In reply to this post by Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# Date 1493167213 25200
#      Tue Apr 25 17:40:13 2017 -0700
# Node ID f9661db975a2e410b860d919ac6436af72b728c3
# Parent  bd01a5b895000ea8791540098b38ae78bed15a2f
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r f9661db975a2
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,6 @@ static PyMethodDef methods[] = {
 };
 
+static const int version = 1;
+
 #ifdef IS_PY3K
 static struct PyModuleDef diffhelpers_module = {
@@ -186,4 +188,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 +196,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
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 4 of 6 V2] mpatch: add version to help detect breaking binary changes

Jun Wu
In reply to this post by Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# Date 1493167116 25200
#      Tue Apr 25 17:38:36 2017 -0700
# Node ID 1cf8daf6404e811cf222f8075edf38265d2bd4c9
# Parent  f9661db975a2e410b860d919ac6436af72b728c3
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 1cf8daf6404e
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,6 @@ static PyMethodDef methods[] = {
 };
 
+static const int version = 1;
+
 #ifdef IS_PY3K
 static struct PyModuleDef mpatch_module = {
@@ -182,4 +184,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 +192,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
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Jun Wu
In reply to this post by Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# 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
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Jun Wu
In reply to this post by Jun Wu
# HG changeset patch
# User Jun Wu <[hidden email]>
# Date 1493167410 25200
#      Tue Apr 25 17:43:30 2017 -0700
# Node ID 67f77153a5d7091f4ce5ff665fd32bd0080f6b1f
# Parent  358a98a28d54b4c7c193e4f631641243d7f55dc7
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 67f77153a5d7
parsers: add version to help detect breaking binary changes

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -2855,6 +2855,10 @@ void dirs_module_init(PyObject *mod);
 void manifest_module_init(PyObject *mod);
 
+static const int version = 1;
+
 static void module_init(PyObject *mod)
 {
+ PyModule_AddIntConstant(mod, "version", version);
+
  /* This module constant has two purposes.  First, it lets us unit test
  * the ImportError raised without hard-coding any error text.  This
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH 2 of 6 V2] base85: add version to help detect breaking binary changes

Yuya Nishihara
In reply to this post by Jun Wu
On Fri, 19 May 2017 08:46:09 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <[hidden email]>
> # Date 1493167548 25200
> #      Tue Apr 25 17:45:48 2017 -0700
> # Node ID bd01a5b895000ea8791540098b38ae78bed15a2f
> # Parent  90ad5352d3c20b5f463d814b46cef15512edbacb
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r bd01a5b89500
> base85: add version to help detect breaking binary changes

Queued the series, thanks!

>  PyMODINIT_FUNC PyInit_base85(void)
>  {
> + PyObject *m;
>   b85prep();
>  
> - return PyModule_Create(&base85_module);
> + m = PyModule_Create(&base85_module);
> + PyModule_AddIntConstant(m, "version", version);
>  }

Added missed 'return m' in flight.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Loading...