File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1070,13 +1070,22 @@ impl WilyIndex {
10701070
10711071 /// Get all rows matching a path (file path or path prefix).
10721072 /// Returns rows where the path equals or starts with the given path.
1073+ /// Rows are sorted by revision_date descending (newest first).
10731074 fn __getitem__ ( & self , py : Python < ' _ > , path : String ) -> PyResult < Py < PyList > > {
10741075 let state = self . state . lock ( ) . map_err ( |e| {
10751076 PyErr :: new :: < pyo3:: exceptions:: PyRuntimeError , _ > ( format ! ( "Lock poisoned: {}" , e) )
10761077 } ) ?;
1078+ // TODO: Decide if we want to filter by path_type as well
1079+ let mut matching_rows: Vec < _ > = state
1080+ . all_rows ( )
1081+ . filter ( |row| row. path == path)
1082+ . cloned ( )
1083+ . collect ( ) ;
10771084
1078- let matching_rows: Vec < _ > = state. all_rows ( ) . filter ( |row| row. path == path) . collect ( ) ;
1085+ // Sort by revision_date ascending (newest last)
1086+ matching_rows. sort_by ( |a, b| a. revision_date . cmp ( & b. revision_date ) ) ;
10791087
1088+ // TODO: There is a more pragmatic way to do this, using PyList::new(py, enumerables)
10801089 let list = PyList :: empty ( py) ;
10811090 for row in matching_rows {
10821091 list. append ( row. to_py_dict ( py) ?) ?;
You can’t perform that action at this time.
0 commit comments