Skip to content
Permalink
Browse files

restore: Make snapshot list human-readable

When restoring from snapshots we should print something that is easy to
understand for humans, not ::registry::snapshot12.

Printing the snapshot ID is required for the --snapshot-id parameter of
restore, but putting it at the front of the line would potentially
confuse users since the selection code also prints numbers, so put it at
the end of the line.
  • Loading branch information
neverpanic committed Mar 11, 2018
1 parent df9633f commit 28ff669e648bbc824268ba38509ddab8a8fc5d5e
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/macports1.0/restore.tcl
@@ -67,9 +67,19 @@ namespace eval restore {
} elseif {[info exists options(ports_restore_last)]} {
set snapshot [fetch_snapshot_last]
} else {
set list [list_snapshots]
set retstring [$macports::ui_options(questions_singlechoice) "Select any one snapshot to restore:" "" $list]
set snapshot [lindex $list $retstring]
set snapshots [list_snapshots]
set human_readable_snapshots {}
foreach snapshot $snapshots {
lappend human_readable_snapshots "[$snapshot note], created at [$snapshot created_at] (ID: [$snapshot id])"
}

if {[llength $snapshots] == 0} {
ui_error "There are no snapshots to restore. You must run 'sudo port snapshot' first."
return 1
}

set retstring [$macports::ui_options(questions_singlechoice) "Select any one snapshot to restore:" "" $human_readable_snapshots]
set snapshot [lindex $snapshots $retstring]

ui_msg "Deactivating all ports installed.."
deactivate_all

0 comments on commit 28ff669

Please sign in to comment.
You can’t perform that action at this time.