rust/hg-cpython/src/revlog.rs
changeset 51259 f20c4b307a5a
parent 51258 9088c6d65ef6
child 51260 5b4995b40db0
equal deleted inserted replaced
51258:9088c6d65ef6 51259:f20c4b307a5a
   302     }
   302     }
   303 
   303 
   304     /// get head revisions
   304     /// get head revisions
   305     def headrevs(&self) -> PyResult<PyObject> {
   305     def headrevs(&self) -> PyResult<PyObject> {
   306         let rust_res = self.inner_headrevs(py)?;
   306         let rust_res = self.inner_headrevs(py)?;
       
   307         Ok(rust_res)
       
   308     }
       
   309 
       
   310     /// get head nodeids
       
   311     def head_node_ids(&self) -> PyResult<PyObject> {
       
   312         let rust_res = self.inner_head_node_ids(py)?;
   307         Ok(rust_res)
   313         Ok(rust_res)
   308     }
   314     }
   309 
   315 
   310     /// get filtered head revisions
   316     /// get filtered head revisions
   311     def headrevsfiltered(&self, *args, **_kw) -> PyResult<PyObject> {
   317     def headrevsfiltered(&self, *args, **_kw) -> PyResult<PyObject> {
   772                 |py_rev| py_rev.into_py_object(py).into_object(),
   778                 |py_rev| py_rev.into_py_object(py).into_object(),
   773             ),
   779             ),
   774         })
   780         })
   775     }
   781     }
   776 
   782 
       
   783     fn inner_head_node_ids(&self, py: Python) -> PyResult<PyObject> {
       
   784         let index = &*self.index(py).borrow();
       
   785 
       
   786         // We don't use the shortcut here, as it's actually slower to loop
       
   787         // through the cached `PyList` than to re-do the whole computation for
       
   788         // large lists, which are the performance sensitive ones anyway.
       
   789         let head_revs = index.head_revs().map_err(|e| graph_error(py, e))?;
       
   790         let res: Vec<_> = head_revs
       
   791             .iter()
       
   792             .map(|r| {
       
   793                 PyBytes::new(
       
   794                     py,
       
   795                     index
       
   796                         .node(*r)
       
   797                         .expect("rev should have been in the index")
       
   798                         .as_bytes(),
       
   799                 )
       
   800                 .into_object()
       
   801             })
       
   802             .collect();
       
   803 
       
   804         self.cache_new_heads_py_list(head_revs, py);
       
   805 
       
   806         Ok(PyList::new(py, &res).into_object())
       
   807     }
       
   808 
   777     fn inner_headrevs(&self, py: Python) -> PyResult<PyObject> {
   809     fn inner_headrevs(&self, py: Python) -> PyResult<PyObject> {
   778         let index = &*self.index(py).borrow();
   810         let index = &*self.index(py).borrow();
   779         if let Some(new_heads) =
   811         if let Some(new_heads) =
   780             index.head_revs_shortcut().map_err(|e| graph_error(py, e))?
   812             index.head_revs_shortcut().map_err(|e| graph_error(py, e))?
   781         {
   813         {