1- //! `smapshot ` subcommand
1+ //! `snapshot ` subcommand
22
33use crate :: {
44 Progress ,
@@ -22,6 +22,7 @@ use crate::{
2222///
2323/// * `repo` - The repository to get the snapshots from.
2424/// * `ids` - The ids of the snapshots to get.
25+ /// * each `id` can use an actual (short) id "01a2b3c4" or "latest" or "latest~N"
2526/// * `group_by` - The criterion to group the snapshots by.
2627/// * `filter` - The filter to apply to the snapshots.
2728///
@@ -37,25 +38,14 @@ pub(crate) fn get_snapshot_group<P: ProgressBars, S: Open>(
3738 let pb = & repo. pb ;
3839 let dbe = repo. dbe ( ) ;
3940 let p = pb. progress_counter ( "getting snapshots..." ) ;
40- let groups = match ids {
41- [ ] => SnapshotFile :: group_from_backend ( dbe, filter, group_by, & p) ?,
42- [ id] if id == "latest" => SnapshotFile :: group_from_backend ( dbe, filter, group_by, & p) ?
43- . into_iter ( )
44- . map ( |( group, mut snaps) | {
45- snaps. sort_unstable ( ) ;
46- let last_idx = snaps. len ( ) - 1 ;
47- snaps. swap ( 0 , last_idx) ;
48- snaps. truncate ( 1 ) ;
49- ( group, snaps)
50- } )
51- . collect :: < Vec < _ > > ( ) ,
52- _ => {
53- let item = (
54- SnapshotGroup :: default ( ) ,
55- SnapshotFile :: from_ids ( dbe, ids, & p) ?,
56- ) ;
57- vec ! [ item]
58- }
41+ let groups = if ids. is_empty ( ) {
42+ SnapshotFile :: group_from_backend ( dbe, filter, group_by, & p) ?
43+ } else {
44+ let item = (
45+ SnapshotGroup :: default ( ) ,
46+ SnapshotFile :: from_strs ( dbe, ids, |_| true , & p) ?,
47+ ) ;
48+ vec ! [ item]
5949 } ;
6050 p. finish ( ) ;
6151
0 commit comments