Closed by commit rHGb43a685edbc7: index: add a `rev` method (API) (authored by 
marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7324?vs=17883&id=17889

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7324/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7324

AFFECTED FILES
  mercurial/cext/parsers.c
  mercurial/cext/revlog.c
  mercurial/policy.py
  mercurial/pure/parsers.py
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -217,6 +217,12 @@
         """return True if the node exist in the index"""
         return node in self.nodemap
 
+    def rev(self, node):
+        """return a revision for a node
+
+        If the node is unknown, raise a RevlogError"""
+        return self.nodemap[node]
+
     def append(self, tup):
         self.nodemap[tup[7]] = len(self)
         super(revlogoldindex, self).append(tup)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -59,6 +59,12 @@
         """return True if the node exist in the index"""
         return node in self.nodemap
 
+    def rev(self, node):
+        """return a revision for a node
+
+        If the node is unknown, raise a RevlogError"""
+        return self.nodemap[node]
+
     def _stripnodes(self, start):
         if 'nodemap' in vars(self):
             for r in range(start, len(self)):
diff --git a/mercurial/policy.py b/mercurial/policy.py
--- a/mercurial/policy.py
+++ b/mercurial/policy.py
@@ -80,7 +80,7 @@
     ('cext', 'bdiff'): 3,
     ('cext', 'mpatch'): 1,
     ('cext', 'osutil'): 4,
-    ('cext', 'parsers'): 14,
+    ('cext', 'parsers'): 15,
 }
 
 # map import request to other package or module
diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -2073,6 +2073,21 @@
        return PyBool_FromLong((long)ret);
 }
 
+static PyObject *index_m_rev(indexObject *self, PyObject *val)
+{
+       char *node;
+       int rev;
+
+       if (node_check(val, &node) == -1)
+               return NULL;
+       rev = index_find_node(self, node, 20);
+       if (rev >= -1)
+               return PyInt_FromLong(rev);
+       if (rev == -2)
+               raise_revlog_error();
+       return NULL;
+}
+
 typedef uint64_t bitmask;
 
 /*
@@ -2733,6 +2748,8 @@
     {"get", (PyCFunction)index_m_get, METH_VARARGS, "get an index entry"},
     {"has_node", (PyCFunction)index_m_has_node, METH_O,
      "return True if the node exist in the index"},
+    {"rev", (PyCFunction)index_m_rev, METH_O,
+     "return `rev` associated with a node or raise RevlogError"},
     {"computephasesmapsets", (PyCFunction)compute_phases_map_sets, 
METH_VARARGS,
      "compute phases"},
     {"reachableroots2", (PyCFunction)reachableroots2, METH_VARARGS,
diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -667,7 +667,7 @@
 void manifest_module_init(PyObject *mod);
 void revlog_module_init(PyObject *mod);
 
-static const int version = 14;
+static const int version = 15;
 
 static void module_init(PyObject *mod)
 {



To: marmoute, indygreg, #hg-reviewers
Cc: martinvonz, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to