(&self)
| 43 | |
| 44 | impl Command for Conflicts { |
| 45 | fn run(&self) -> CliResult<()> { |
| 46 | // Route through the daemon when reachable (a read; the render |
| 47 | // comes from the wire's ConflictInfo kind/line/sides). |
| 48 | if crate::commands::rpc::conflicts(self.short)? { |
| 49 | return Ok(()); |
| 50 | } |
| 51 | |
| 52 | let repo_root = find_repository_root()?; |
| 53 | let repo = crate::commands::open_readonly_repository(&repo_root).map_err(|e| { |
| 54 | CliError::InvalidRepository { |
| 55 | reason: e.to_string(), |
| 56 | } |
| 57 | })?; |
| 58 | |
| 59 | let working_copy = repo |
| 60 | .require_working_copy_id() |
| 61 | .map_err(|e| CliError::Internal(e.into()))?; |
| 62 | let conflicts = repo |
| 63 | .list_conflicts(working_copy) |
| 64 | .map_err(|e| CliError::Internal(e.into()))?; |
| 65 | |
| 66 | if self.short { |
| 67 | for (path, records) in &conflicts { |
| 68 | for c in records { |
| 69 | let line = c.line.map(|l| l.to_string()).unwrap_or_else(|| "-".into()); |
| 70 | println!("{}:{}:{}", path, line, c.kind); |
| 71 | } |
| 72 | } |
| 73 | return Ok(()); |
| 74 | } |
| 75 | |
| 76 | if conflicts.is_empty() { |
| 77 | print_success("No conflicts."); |
| 78 | return Ok(()); |
| 79 | } |
| 80 | |
| 81 | let file_word = if conflicts.len() == 1 { |
| 82 | "file" |
| 83 | } else { |
| 84 | "files" |
| 85 | }; |
| 86 | println!( |
| 87 | "{}", |
| 88 | warning(&format!("{} conflicted {}:", conflicts.len(), file_word)) |
| 89 | ); |
| 90 | print_blank(); |
| 91 | |
| 92 | for (path, records) in &conflicts { |
| 93 | println!("\t{}", style_path(path)); |
| 94 | for c in records { |
| 95 | let where_ = match c.line { |
| 96 | Some(l) => format!("line {}", l), |
| 97 | None => "unknown line".to_string(), |
| 98 | }; |
| 99 | if c.sides.is_empty() { |
| 100 | println!("\t {} conflict at {}", c.kind, where_); |
| 101 | } else { |
| 102 | let sides = c |
nothing calls this directly
no test coverage detected