Show More
@@ -305,6 +305,10 b' class filteredchangelogmixin:' | |||||
305 | raise error.FilteredIndexError(rev) |
|
305 | raise error.FilteredIndexError(rev) | |
306 | return revs |
|
306 | return revs | |
307 |
|
307 | |||
|
308 | def _head_node_ids(self): | |||
|
309 | # no Rust fast path implemented yet, so just loop in Python | |||
|
310 | return [self.node(r) for r in self.headrevs()] | |||
|
311 | ||||
308 | def headrevs(self, revs=None): |
|
312 | def headrevs(self, revs=None): | |
309 | if revs is None: |
|
313 | if revs is None: | |
310 | try: |
|
314 | try: |
@@ -2362,6 +2362,12 b' class revlog:' | |||||
2362 | ishead[e[5]] = ishead[e[6]] = 0 # my parent are not |
|
2362 | ishead[e[5]] = ishead[e[6]] = 0 # my parent are not | |
2363 | return [r for r, val in enumerate(ishead) if val] |
|
2363 | return [r for r, val in enumerate(ishead) if val] | |
2364 |
|
2364 | |||
|
2365 | def _head_node_ids(self): | |||
|
2366 | try: | |||
|
2367 | return self.index.head_node_ids() | |||
|
2368 | except AttributeError: | |||
|
2369 | return [self.node(r) for r in self.headrevs()] | |||
|
2370 | ||||
2365 | def heads(self, start=None, stop=None): |
|
2371 | def heads(self, start=None, stop=None): | |
2366 | """return the list of all nodes that have no children |
|
2372 | """return the list of all nodes that have no children | |
2367 |
|
2373 | |||
@@ -2373,8 +2379,7 b' class revlog:' | |||||
2373 | if start is None and stop is None: |
|
2379 | if start is None and stop is None: | |
2374 | if not len(self): |
|
2380 | if not len(self): | |
2375 | return [self.nullid] |
|
2381 | return [self.nullid] | |
2376 |
return |
|
2382 | return self._head_node_ids() | |
2377 |
|
||||
2378 | if start is None: |
|
2383 | if start is None: | |
2379 | start = nullrev |
|
2384 | start = nullrev | |
2380 | else: |
|
2385 | else: |
@@ -307,6 +307,12 b' py_class!(pub class Index |py| {' | |||||
307 | Ok(rust_res) |
|
307 | Ok(rust_res) | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
|
310 | /// get head nodeids | |||
|
311 | def head_node_ids(&self) -> PyResult<PyObject> { | |||
|
312 | let rust_res = self.inner_head_node_ids(py)?; | |||
|
313 | Ok(rust_res) | |||
|
314 | } | |||
|
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> { | |
312 | let rust_res = self.inner_headrevsfiltered(py, &args.get_item(py, 0))?; |
|
318 | let rust_res = self.inner_headrevsfiltered(py, &args.get_item(py, 0))?; | |
@@ -774,6 +780,32 b' impl Index {' | |||||
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) = |
General Comments 0
You need to be logged in to leave comments.
Login now