MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / view_list

Function view_list

atomic-cli/src/commands/rpc.rs:3014–3096  ·  view source on GitHub ↗

`atomic view list` over ListViews — every local form (`--remote` is the scope-out remote surface). The wire's ViewInfo carries each view's own/inherited change-count split and head state, so the versioned JSON document renders client-side with the same JsonView shape the local body emits; the plain form keeps its metadata rendering.

(args: &super::view::List)

Source from the content-addressed store, hash-verified

3012/// document renders client-side with the same JsonView shape the local
3013/// body emits; the plain form keeps its metadata rendering.
3014pub fn view_list(args: &super::view::List) -> CliResult<bool> {
3015 if args.remote.is_some() {
3016 return Ok(false); // the remote listing (scope-out remote surface)
3017 }
3018 // `view list` is #207's explicit registration/migration entry for a new
3019 // linked worktree or an older native repository. Migrate before opening
3020 // the service session; ListViews itself keeps its read-only contract.
3021 if let Ok(root) = super::find_repository_root() {
3022 match atomic_repository::Repository::open_readonly_wait(
3023 &root,
3024 atomic_repository::database_lock_wait(),
3025 ) {
3026 Ok(_) => {}
3027 Err(atomic_repository::RepositoryError::WorkingCopyMigrationRequired { .. }) => {
3028 drop(atomic_repository::Repository::open(&root).map_err(CliError::Repository)?);
3029 }
3030 Err(error) => {
3031 // Inspect the schema without requiring its completion. Do not
3032 // turn arbitrary query errors into a writable recovery open.
3033 let needs_path_migration =
3034 atomic_repository::Repository::open_readonly_for_native_repair(&root)
3035 .and_then(|repo| repo.path_claim_migration_required())
3036 .unwrap_or(false);
3037 if !needs_path_migration {
3038 return Err(CliError::Repository(error));
3039 }
3040 drop(atomic_repository::Repository::open(&root).map_err(CliError::Repository)?);
3041 }
3042 }
3043 }
3044 let Some(session) = Service::open()? else {
3045 return Ok(false);
3046 };
3047 let response = session.list_views(pb::ListViewsRequest {
3048 repository: Some(session.reference.clone()),
3049 include_details: false,
3050 })?;
3051 if args.json {
3052 let mut json_views = response
3053 .views
3054 .iter()
3055 .map(super::view::list::JsonView::from_wire)
3056 .collect::<Vec<_>>();
3057 json_views.sort_by(|left, right| left.name.cmp(&right.name));
3058 let current = response
3059 .views
3060 .iter()
3061 .find(|view| view.current)
3062 .map(|view| view.name.clone());
3063 super::view::list::print_local_json(&json_views, current)?;
3064 return Ok(true);
3065 }
3066 let entries: Vec<super::view::list::ViewEntry> = response
3067 .views
3068 .iter()
3069 .map(super::view::list::ViewEntry::from_wire)
3070 .collect();
3071

Callers 1

runMethod · 0.85

Calls 15

find_repository_rootFunction · 0.85
database_lock_waitFunction · 0.85
RepositoryClass · 0.85
print_local_jsonFunction · 0.85
compute_visibilityFunction · 0.85
tree_orderFunction · 0.85
render_short_lineFunction · 0.85
render_lineFunction · 0.85
print_hintFunction · 0.85
summary_lineFunction · 0.85
openFunction · 0.50

Tested by

no test coverage detected