Show More
@@ -255,75 +255,36 b' pub fn run(invocation: &crate::CliInvoca' | |||
|
255 | 255 | } |
|
256 | 256 | } |
|
257 | 257 | } |
|
258 | let relative_paths = (!ui.plain()) | |
|
259 | && config | |
|
260 | .get_option(b"commands", b"status.relative")? | |
|
261 | .unwrap_or(config.get_bool(b"ui", b"relative-paths")?); | |
|
262 | let output = DisplayStatusPaths { | |
|
263 | ui, | |
|
264 | repo, | |
|
265 | no_status, | |
|
266 | relative_paths, | |
|
267 | }; | |
|
258 | 268 | if display_states.modified { |
|
259 | display_status_paths( | |
|
260 | ui, | |
|
261 | repo, | |
|
262 | config, | |
|
263 | no_status, | |
|
264 | &mut ds_status.modified, | |
|
265 | b"M", | |
|
266 | )?; | |
|
269 | output.display(b"M", ds_status.modified)?; | |
|
267 | 270 | } |
|
268 | 271 | if display_states.added { |
|
269 |
display |
|
|
270 | ui, | |
|
271 | repo, | |
|
272 | config, | |
|
273 | no_status, | |
|
274 | &mut ds_status.added, | |
|
275 | b"A", | |
|
276 | )?; | |
|
272 | output.display(b"A", ds_status.added)?; | |
|
277 | 273 | } |
|
278 | 274 | if display_states.removed { |
|
279 | display_status_paths( | |
|
280 | ui, | |
|
281 | repo, | |
|
282 | config, | |
|
283 | no_status, | |
|
284 | &mut ds_status.removed, | |
|
285 | b"R", | |
|
286 | )?; | |
|
275 | output.display(b"R", ds_status.removed)?; | |
|
287 | 276 | } |
|
288 | 277 | if display_states.deleted { |
|
289 | display_status_paths( | |
|
290 | ui, | |
|
291 | repo, | |
|
292 | config, | |
|
293 | no_status, | |
|
294 | &mut ds_status.deleted, | |
|
295 | b"!", | |
|
296 | )?; | |
|
278 | output.display(b"!", ds_status.deleted)?; | |
|
297 | 279 | } |
|
298 | 280 | if display_states.unknown { |
|
299 | display_status_paths( | |
|
300 | ui, | |
|
301 | repo, | |
|
302 | config, | |
|
303 | no_status, | |
|
304 | &mut ds_status.unknown, | |
|
305 | b"?", | |
|
306 | )?; | |
|
281 | output.display(b"?", ds_status.unknown)?; | |
|
307 | 282 | } |
|
308 | 283 | if display_states.ignored { |
|
309 | display_status_paths( | |
|
310 | ui, | |
|
311 | repo, | |
|
312 | config, | |
|
313 | no_status, | |
|
314 | &mut ds_status.ignored, | |
|
315 | b"I", | |
|
316 | )?; | |
|
284 | output.display(b"I", ds_status.ignored)?; | |
|
317 | 285 | } |
|
318 | 286 | if display_states.clean { |
|
319 |
display |
|
|
320 | ui, | |
|
321 | repo, | |
|
322 | config, | |
|
323 | no_status, | |
|
324 | &mut ds_status.clean, | |
|
325 | b"C", | |
|
326 | )?; | |
|
287 | output.display(b"C", ds_status.clean)?; | |
|
327 | 288 | } |
|
328 | 289 | |
|
329 | 290 | let mut dirstate_write_needed = ds_status.dirty; |
@@ -416,41 +377,47 b' fn ignore_files(repo: &Repo, config: &Co' | |||
|
416 | 377 | ignore_files |
|
417 | 378 | } |
|
418 | 379 | |
|
419 | // Probably more elegant to use a Deref or Borrow trait rather than | |
|
420 | // harcode HgPathBuf, but probably not really useful at this point | |
|
421 | fn display_status_paths( | |
|
422 | ui: &Ui, | |
|
423 | repo: &Repo, | |
|
424 | config: &Config, | |
|
380 | struct DisplayStatusPaths<'a> { | |
|
381 | ui: &'a Ui, | |
|
382 | repo: &'a Repo, | |
|
425 | 383 | no_status: bool, |
|
426 | paths: &mut [HgPathCow], | |
|
427 | status_prefix: &[u8], | |
|
428 | ) -> Result<(), CommandError> { | |
|
429 | paths.sort_unstable(); | |
|
430 | let mut relative: bool = config.get_bool(b"ui", b"relative-paths")?; | |
|
431 | relative = config | |
|
432 | .get_option(b"commands", b"status.relative")? | |
|
433 | .unwrap_or(relative); | |
|
434 | let print_path = |path: &[u8]| { | |
|
435 | // TODO optim, probably lots of unneeded copies here, especially | |
|
436 | // if out stream is buffered | |
|
437 | if no_status { | |
|
438 | ui.write_stdout(&format_bytes!(b"{}\n", path)) | |
|
384 | relative_paths: bool, | |
|
385 | } | |
|
386 | ||
|
387 | impl DisplayStatusPaths<'_> { | |
|
388 | // Probably more elegant to use a Deref or Borrow trait rather than | |
|
389 | // harcode HgPathBuf, but probably not really useful at this point | |
|
390 | fn display( | |
|
391 | &self, | |
|
392 | status_prefix: &[u8], | |
|
393 | mut paths: Vec<HgPathCow>, | |
|
394 | ) -> Result<(), CommandError> { | |
|
395 | paths.sort_unstable(); | |
|
396 | let print_path = |path: &[u8]| { | |
|
397 | // TODO optim, probably lots of unneeded copies here, especially | |
|
398 | // if out stream is buffered | |
|
399 | if self.no_status { | |
|
400 | self.ui.write_stdout(&format_bytes!(b"{}\n", path)) | |
|
401 | } else { | |
|
402 | self.ui.write_stdout(&format_bytes!( | |
|
403 | b"{} {}\n", | |
|
404 | status_prefix, | |
|
405 | path | |
|
406 | )) | |
|
407 | } | |
|
408 | }; | |
|
409 | ||
|
410 | if self.relative_paths { | |
|
411 | relativize_paths(self.repo, paths.iter().map(Ok), |path| { | |
|
412 | print_path(&path) | |
|
413 | })?; | |
|
439 | 414 | } else { |
|
440 | ui.write_stdout(&format_bytes!(b"{} {}\n", status_prefix, path)) | |
|
415 | for path in paths { | |
|
416 | print_path(path.as_bytes())? | |
|
417 | } | |
|
441 | 418 | } |
|
442 | }; | |
|
443 | ||
|
444 | if relative && !ui.plain() { | |
|
445 | relativize_paths(repo, paths.iter().map(Ok), |path| { | |
|
446 | print_path(&path) | |
|
447 | })?; | |
|
448 | } else { | |
|
449 | for path in paths { | |
|
450 | print_path(path.as_bytes())? | |
|
451 | } | |
|
419 | Ok(()) | |
|
452 | 420 | } |
|
453 | Ok(()) | |
|
454 | 421 | } |
|
455 | 422 | |
|
456 | 423 | /// Check if a file is modified by comparing actual repo store and file system. |
General Comments 0
You need to be logged in to leave comments.
Login now