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