rust/hg-core/src/repo.rs
changeset 49930 e98fd81bb151
parent 49217 13dfad0f9f7a
child 49937 750409505286
--- a/rust/hg-core/src/repo.rs	Mon Jan 09 19:14:14 2023 +0100
+++ b/rust/hg-core/src/repo.rs	Mon Jan 09 19:18:43 2023 +0100
@@ -68,9 +68,9 @@
                 return Ok(ancestor.to_path_buf());
             }
         }
-        return Err(RepoError::NotFound {
+        Err(RepoError::NotFound {
             at: current_directory,
-        });
+        })
     }
 
     /// Find a repository, either at the given path (which must contain a `.hg`
@@ -87,13 +87,11 @@
     ) -> Result<Self, RepoError> {
         if let Some(root) = explicit_path {
             if is_dir(root.join(".hg"))? {
-                Self::new_at_path(root.to_owned(), config)
+                Self::new_at_path(root, config)
             } else if is_file(&root)? {
                 Err(HgError::unsupported("bundle repository").into())
             } else {
-                Err(RepoError::NotFound {
-                    at: root.to_owned(),
-                })
+                Err(RepoError::NotFound { at: root })
             }
         } else {
             let root = Self::find_repo_root()?;
@@ -108,9 +106,8 @@
     ) -> Result<Self, RepoError> {
         let dot_hg = working_directory.join(".hg");
 
-        let mut repo_config_files = Vec::new();
-        repo_config_files.push(dot_hg.join("hgrc"));
-        repo_config_files.push(dot_hg.join("hgrc-not-shared"));
+        let mut repo_config_files =
+            vec![dot_hg.join("hgrc"), dot_hg.join("hgrc-not-shared")];
 
         let hg_vfs = Vfs { base: &dot_hg };
         let mut reqs = requirements::load_if_exists(hg_vfs)?;
@@ -254,7 +251,7 @@
             .hg_vfs()
             .read("dirstate")
             .io_not_found_as_none()?
-            .unwrap_or(Vec::new()))
+            .unwrap_or_default())
     }
 
     pub fn dirstate_parents(&self) -> Result<DirstateParents, HgError> {
@@ -277,8 +274,7 @@
                 .set(Some(docket.uuid.to_owned()));
             docket.parents()
         } else {
-            crate::dirstate::parsers::parse_dirstate_parents(&dirstate)?
-                .clone()
+            *crate::dirstate::parsers::parse_dirstate_parents(&dirstate)?
         };
         self.dirstate_parents.set(parents);
         Ok(parents)