Patchwork [2,of,6] revlog: export symbol of indexType

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 5, 2018, 1:43 p.m.
Message ID <7d8bcaf492259a58190f.1544017413@mimosa>
Download mbox | patch
Permalink /patch/36975/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 5, 2018, 1:43 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1543754262 -32400
#      Sun Dec 02 21:37:42 2018 +0900
# Node ID 7d8bcaf492259a58190f2e34a10db6399ba7b096
# Parent  b5ddfb2991c8c41b2e9e22e920afd57c80d9153c
revlog: export symbol of indexType

The idea is to wrap the index object with rust-cpython. I haven't tried it,
but it should be doable. We'll probably need a better interface than raw
function pointers to do more in Rust.

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -17,6 +17,7 @@ 
 
 #include "bitmanipulation.h"
 #include "charencode.h"
+#include "revlog.h"
 #include "util.h"
 
 #ifdef IS_PY3K
@@ -1511,8 +1512,6 @@  static int nt_init(nodetree *self, index
 	return 0;
 }
 
-static PyTypeObject indexType;
-
 static int ntobj_init(nodetreeObject *self, PyObject *args)
 {
 	PyObject *index;
@@ -2582,7 +2581,7 @@  static PyGetSetDef index_getset[] = {
     {NULL} /* Sentinel */
 };
 
-static PyTypeObject indexType = {
+PyTypeObject indexType = {
     PyVarObject_HEAD_INIT(NULL, 0) /* header */
     "parsers.index",               /* tp_name */
     sizeof(indexObject),           /* tp_basicsize */
diff --git a/mercurial/cext/revlog.h b/mercurial/cext/revlog.h
new file mode 100644
--- /dev/null
+++ b/mercurial/cext/revlog.h
@@ -0,0 +1,15 @@ 
+/*
+ revlog.h - efficient revlog parsing
+
+ This software may be used and distributed according to the terms of
+ the GNU General Public License, incorporated herein by reference.
+*/
+
+#ifndef _HG_REVLOG_H_
+#define _HG_REVLOG_H_
+
+#include <Python.h>
+
+extern PyTypeObject indexType;
+
+#endif /* _HG_REVLOG_H_ */
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -968,6 +968,7 @@  extmodules = [
                   'hg-direct-ffi',
                   include_dirs=common_include_dirs,
                   depends=common_depends + ['mercurial/cext/charencode.h',
+                                            'mercurial/cext/revlog.h',
                                             'rust/hg-core/src/ancestors.rs',
                                             'rust/hg-core/src/lib.rs']),
     Extension('mercurial.cext.osutil', ['mercurial/cext/osutil.c'],