(&self)
| 1047 | } |
| 1048 | |
| 1049 | fn run_import(&self) -> CliResult<()> { |
| 1050 | let run_start = std::time::Instant::now(); |
| 1051 | if self.stream || self.uses_span() || self.stream_window_mib.is_some() { |
| 1052 | self.stream_limits()?; |
| 1053 | } |
| 1054 | if self.no_stream && self.stream { |
| 1055 | return Err(CliError::GitError { |
| 1056 | message: "--stream and --no-stream cannot be combined".into(), |
| 1057 | }); |
| 1058 | } |
| 1059 | // Open Git repository |
| 1060 | let git_repo = GitRepository::discover(".").map_err(|_| CliError::GitError { |
| 1061 | message: "Not a git repository (or any parent up to mount point)".to_string(), |
| 1062 | })?; |
| 1063 | |
| 1064 | let workdir = git_repo.workdir().ok_or_else(|| CliError::GitError { |
| 1065 | message: "Git repository has no working directory (bare repository?)".to_string(), |
| 1066 | })?; |
| 1067 | #[cfg(feature = "experimental-span-import")] |
| 1068 | if self.span && self.incremental { |
| 1069 | return self.run_span_incremental(&git_repo, workdir); |
| 1070 | } |
| 1071 | // Keep capability inspection and the later workspace entry under one |
| 1072 | // common lock. Never run writable recovery before this check: the |
| 1073 | // ordinary importer cannot publish into a span-backed repository. |
| 1074 | let _import_preflight = Repository::try_lock_git_import_without_span(workdir, self.dry_run) |
| 1075 | .map_err(|error| CliError::GitError { |
| 1076 | message: format!("Git import preflight refused: {error}"), |
| 1077 | })?; |
| 1078 | if self.uses_span() && workdir.join(".atomic").exists() { |
| 1079 | return Err(CliError::GitError { |
| 1080 | message: "--span requires a fresh Git checkout without an Atomic repository".into(), |
| 1081 | }); |
| 1082 | } |
| 1083 | trace_git_import(format!( |
| 1084 | "discover Git repository: {:?}", |
| 1085 | run_start.elapsed() |
| 1086 | )); |
| 1087 | |
| 1088 | // Dry run mode |
| 1089 | if self.dry_run { |
| 1090 | print_info("Dry run mode - no changes will be made"); |
| 1091 | |
| 1092 | let default_branch = self.get_default_branch(&git_repo)?; |
| 1093 | let branches = if self.all_branches { |
| 1094 | self.get_all_branches(&git_repo)? |
| 1095 | } else { |
| 1096 | vec![self.branch.clone().unwrap_or(default_branch)] |
| 1097 | }; |
| 1098 | |
| 1099 | // For an incremental forecast, open the existing Atomic repo |
| 1100 | // read-only so we can subtract what each branch's view already |
| 1101 | // contains. A fresh (not-yet-initialized) repo has nothing |
| 1102 | // imported, so the forecast is the full history — which is correct. |
| 1103 | // The dry run selects the explicit Observe mode: it never mutates. |
| 1104 | // Ordinary read-only opens now migrate the legacy database layout. |
| 1105 | // Require that migration separately rather than move files in a preview. |
| 1106 | if self.incremental |
no test coverage detected