rust/hg-core/src/dirstate/status.rs
changeset 46494 d67732a4b58a
parent 46444 6c778d20c8c2
parent 46489 fb6eca7b8c63
child 46757 3c9ddb1986a9
equal deleted inserted replaced
46486:d7685105e504 46494:d67732a4b58a
   774     /// This takes a mutable reference to the results to account for the
   774     /// This takes a mutable reference to the results to account for the
   775     /// `extend` in timings
   775     /// `extend` in timings
   776     #[cfg(not(feature = "dirstate-tree"))]
   776     #[cfg(not(feature = "dirstate-tree"))]
   777     #[timed]
   777     #[timed]
   778     pub fn extend_from_dmap(&self, results: &mut Vec<DispatchedPath<'a>>) {
   778     pub fn extend_from_dmap(&self, results: &mut Vec<DispatchedPath<'a>>) {
   779         results.par_extend(self.dmap.par_iter().map(
   779         results.par_extend(
   780             move |(filename, entry)| {
   780             self.dmap
   781                 let filename: &HgPath = filename;
   781                 .par_iter()
   782                 let filename_as_path = match hg_path_to_path_buf(filename) {
   782                 .filter(|(path, _)| self.matcher.matches(path))
   783                     Ok(f) => f,
   783                 .map(move |(filename, entry)| {
   784                     Err(_) => {
   784                     let filename: &HgPath = filename;
   785                         return (
   785                     let filename_as_path = match hg_path_to_path_buf(filename)
       
   786                     {
       
   787                         Ok(f) => f,
       
   788                         Err(_) => {
       
   789                             return (
       
   790                                 Cow::Borrowed(filename),
       
   791                                 INVALID_PATH_DISPATCH,
       
   792                             )
       
   793                         }
       
   794                     };
       
   795                     let meta = self
       
   796                         .root_dir
       
   797                         .join(filename_as_path)
       
   798                         .symlink_metadata();
       
   799                     match meta {
       
   800                         Ok(m)
       
   801                             if !(m.file_type().is_file()
       
   802                                 || m.file_type().is_symlink()) =>
       
   803                         {
       
   804                             (
       
   805                                 Cow::Borrowed(filename),
       
   806                                 dispatch_missing(entry.state),
       
   807                             )
       
   808                         }
       
   809                         Ok(m) => (
   786                             Cow::Borrowed(filename),
   810                             Cow::Borrowed(filename),
   787                             INVALID_PATH_DISPATCH,
   811                             dispatch_found(
   788                         )
   812                                 filename,
       
   813                                 *entry,
       
   814                                 HgMetadata::from_metadata(m),
       
   815                                 &self.dmap.copy_map,
       
   816                                 self.options,
       
   817                             ),
       
   818                         ),
       
   819                         Err(e)
       
   820                             if e.kind() == ErrorKind::NotFound
       
   821                                 || e.raw_os_error() == Some(20) =>
       
   822                         {
       
   823                             // Rust does not yet have an `ErrorKind` for
       
   824                             // `NotADirectory` (errno 20)
       
   825                             // It happens if the dirstate contains `foo/bar`
       
   826                             // and foo is not a
       
   827                             // directory
       
   828                             (
       
   829                                 Cow::Borrowed(filename),
       
   830                                 dispatch_missing(entry.state),
       
   831                             )
       
   832                         }
       
   833                         Err(e) => {
       
   834                             (Cow::Borrowed(filename), dispatch_os_error(&e))
       
   835                         }
   789                     }
   836                     }
   790                 };
   837                 }),
   791                 let meta =
   838         );
   792                     self.root_dir.join(filename_as_path).symlink_metadata();
       
   793                 match meta {
       
   794                     Ok(m)
       
   795                         if !(m.file_type().is_file()
       
   796                             || m.file_type().is_symlink()) =>
       
   797                     {
       
   798                         (
       
   799                             Cow::Borrowed(filename),
       
   800                             dispatch_missing(entry.state),
       
   801                         )
       
   802                     }
       
   803                     Ok(m) => (
       
   804                         Cow::Borrowed(filename),
       
   805                         dispatch_found(
       
   806                             filename,
       
   807                             *entry,
       
   808                             HgMetadata::from_metadata(m),
       
   809                             &self.dmap.copy_map,
       
   810                             self.options,
       
   811                         ),
       
   812                     ),
       
   813                     Err(e)
       
   814                         if e.kind() == ErrorKind::NotFound
       
   815                             || e.raw_os_error() == Some(20) =>
       
   816                     {
       
   817                         // Rust does not yet have an `ErrorKind` for
       
   818                         // `NotADirectory` (errno 20)
       
   819                         // It happens if the dirstate contains `foo/bar`
       
   820                         // and foo is not a
       
   821                         // directory
       
   822                         (
       
   823                             Cow::Borrowed(filename),
       
   824                             dispatch_missing(entry.state),
       
   825                         )
       
   826                     }
       
   827                     Err(e) => (Cow::Borrowed(filename), dispatch_os_error(&e)),
       
   828                 }
       
   829             },
       
   830         ));
       
   831     }
   839     }
   832 
   840 
   833     /// Checks all files that are in the dirstate but were not found during the
   841     /// Checks all files that are in the dirstate but were not found during the
   834     /// working directory traversal. This means that the rest must
   842     /// working directory traversal. This means that the rest must
   835     /// be either ignored, under a symlink or under a new nested repo.
   843     /// be either ignored, under a symlink or under a new nested repo.