##// END OF EJS Templates
index: add a `rev` method (API)...
marmoute -
r43952:bd87114c default
parent child Browse files
Show More
@@ -667,7 +667,7 b' void dirs_module_init(PyObject *mod);'
667 void manifest_module_init(PyObject *mod);
667 void manifest_module_init(PyObject *mod);
668 void revlog_module_init(PyObject *mod);
668 void revlog_module_init(PyObject *mod);
669
669
670 static const int version = 14;
670 static const int version = 15;
671
671
672 static void module_init(PyObject *mod)
672 static void module_init(PyObject *mod)
673 {
673 {
@@ -2073,6 +2073,21 b' static PyObject *index_m_has_node(indexO'
2073 return PyBool_FromLong((long)ret);
2073 return PyBool_FromLong((long)ret);
2074 }
2074 }
2075
2075
2076 static PyObject *index_m_rev(indexObject *self, PyObject *val)
2077 {
2078 char *node;
2079 int rev;
2080
2081 if (node_check(val, &node) == -1)
2082 return NULL;
2083 rev = index_find_node(self, node, 20);
2084 if (rev >= -1)
2085 return PyInt_FromLong(rev);
2086 if (rev == -2)
2087 raise_revlog_error();
2088 return NULL;
2089 }
2090
2076 typedef uint64_t bitmask;
2091 typedef uint64_t bitmask;
2077
2092
2078 /*
2093 /*
@@ -2733,6 +2748,8 b' static PyMethodDef index_methods[] = {'
2733 {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"},
2748 {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"},
2734 {"has_node", (PyCFunction)index_m_has_node, METH_O,
2749 {"has_node", (PyCFunction)index_m_has_node, METH_O,
2735 "return True if the node exist in the index"},
2750 "return True if the node exist in the index"},
2751 {"rev", (PyCFunction)index_m_rev, METH_O,
2752 "return `rev` associated with a node or raise RevlogError"},
2736 {"computephasesmapsets", (PyCFunction)compute_phases_map_sets, METH_VARARGS,
2753 {"computephasesmapsets", (PyCFunction)compute_phases_map_sets, METH_VARARGS,
2737 "compute phases"},
2754 "compute phases"},
2738 {"reachableroots2", (PyCFunction)reachableroots2, METH_VARARGS,
2755 {"reachableroots2", (PyCFunction)reachableroots2, METH_VARARGS,
@@ -80,7 +80,7 b' def _importfrom(pkgname, modname):'
80 ('cext', 'bdiff'): 3,
80 ('cext', 'bdiff'): 3,
81 ('cext', 'mpatch'): 1,
81 ('cext', 'mpatch'): 1,
82 ('cext', 'osutil'): 4,
82 ('cext', 'osutil'): 4,
83 ('cext', 'parsers'): 14,
83 ('cext', 'parsers'): 15,
84 }
84 }
85
85
86 # map import request to other package or module
86 # map import request to other package or module
@@ -59,6 +59,12 b' class BaseIndexObject(object):'
59 """return True if the node exist in the index"""
59 """return True if the node exist in the index"""
60 return node in self.nodemap
60 return node in self.nodemap
61
61
62 def rev(self, node):
63 """return a revision for a node
64
65 If the node is unknown, raise a RevlogError"""
66 return self.nodemap[node]
67
62 def _stripnodes(self, start):
68 def _stripnodes(self, start):
63 if 'nodemap' in vars(self):
69 if 'nodemap' in vars(self):
64 for r in range(start, len(self)):
70 for r in range(start, len(self)):
@@ -217,6 +217,12 b' class revlogoldindex(list):'
217 """return True if the node exist in the index"""
217 """return True if the node exist in the index"""
218 return node in self.nodemap
218 return node in self.nodemap
219
219
220 def rev(self, node):
221 """return a revision for a node
222
223 If the node is unknown, raise a RevlogError"""
224 return self.nodemap[node]
225
220 def append(self, tup):
226 def append(self, tup):
221 self.nodemap[tup[7]] = len(self)
227 self.nodemap[tup[7]] = len(self)
222 super(revlogoldindex, self).append(tup)
228 super(revlogoldindex, self).append(tup)
General Comments 0
You need to be logged in to leave comments. Login now