rust-status: don't dispatch unknown file when traversing if not listing unknowns
authorRaphaël Gomès <rgomes@octobus.net>
Tue, 12 May 2020 12:41:28 +0200
changeset 44837 dc60ba32d43b
parent 44836 63edfea7dfde
child 44838 c802ec4f7196
rust-status: don't dispatch unknown file when traversing if not listing unknowns This usually isn't a (functional) problem since we ignore the unknown files anyway, but when specifically using `hg purge`, unknown files were iterated over regardless of the option being true. This is both more correct and more efficient. Differential Revision: https://phab.mercurial-scm.org/D8517
rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs	Tue May 12 10:03:51 2020 +0200
+++ b/rust/hg-core/src/dirstate/status.rs	Tue May 12 12:41:28 2020 +0200
@@ -371,9 +371,11 @@
                         .unwrap();
                 }
             } else {
-                files_sender
-                    .send(Ok((filename.to_owned(), Dispatch::Unknown)))
-                    .unwrap();
+                if options.list_unknown {
+                    files_sender
+                        .send(Ok((filename.to_owned(), Dispatch::Unknown)))
+                        .unwrap();
+                }
             }
         } else if ignore_fn(&filename) && options.list_ignored {
             files_sender