##// END OF EJS Templates
index: add a `get_rev` method (API)...
marmoute -
r43861:9db20dcf default draft
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 = 15;
670 static const int version = 16;
671
671
672 static void module_init(PyObject *mod)
672 static void module_init(PyObject *mod)
673 {
673 {
@@ -2746,6 +2746,8 b' static PyMethodDef index_methods[] = {'
2746 {"clearcaches", (PyCFunction)index_clearcaches, METH_NOARGS,
2746 {"clearcaches", (PyCFunction)index_clearcaches, METH_NOARGS,
2747 "clear the index caches"},
2747 "clear the index caches"},
2748 {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"},
2748 {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"},
2749 {"get_rev", (PyCFunction)index_m_get, METH_VARARGS,
2750 "return `rev` associated with a node or None"},
2749 {"has_node", (PyCFunction)index_m_has_node, METH_O,
2751 {"has_node", (PyCFunction)index_m_has_node, METH_O,
2750 "return True if the node exist in the index"},
2752 "return True if the node exist in the index"},
2751 {"rev", (PyCFunction)index_m_rev, METH_O,
2753 {"rev", (PyCFunction)index_m_rev, METH_O,
@@ -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'): 15,
83 ('cext', 'parsers'): 16,
84 }
84 }
85
85
86 # map import request to other package or module
86 # map import request to other package or module
@@ -65,6 +65,12 b' class BaseIndexObject(object):'
65 If the node is unknown, raise a RevlogError"""
65 If the node is unknown, raise a RevlogError"""
66 return self.nodemap[node]
66 return self.nodemap[node]
67
67
68 def get_rev(self, node):
69 """return a revision for a node
70
71 If the node is unknown, return None"""
72 return self.nodemap.get(node)
73
68 def _stripnodes(self, start):
74 def _stripnodes(self, start):
69 if 'nodemap' in vars(self):
75 if 'nodemap' in vars(self):
70 for r in range(start, len(self)):
76 for r in range(start, len(self)):
@@ -223,6 +223,12 b' class revlogoldindex(list):'
223 If the node is unknown, raise a RevlogError"""
223 If the node is unknown, raise a RevlogError"""
224 return self.nodemap[node]
224 return self.nodemap[node]
225
225
226 def get_rev(self, node):
227 """return a revision for a node
228
229 If the node is unknown, return None"""
230 return self.nodemap.get(node)
231
226 def append(self, tup):
232 def append(self, tup):
227 self.nodemap[tup[7]] = len(self)
233 self.nodemap[tup[7]] = len(self)
228 super(revlogoldindex, self).append(tup)
234 super(revlogoldindex, self).append(tup)
General Comments 0
You need to be logged in to leave comments. Login now