| @@ -1,5 +1,5 @@ |
| 1 | | −use crate::graph_file::GraphFile; |
| 2 | | −use crate::{graph_file, Graph, MAX_COMMITS}; |
| 1 | +use crate::file::File; |
| 2 | +use crate::{file, Graph, MAX_COMMITS}; |
| 3 | 3 | use git_object::HashKind; |
| 4 | 4 | use quick_error::quick_error; |
| 5 | 5 | use std::io::{BufRead, BufReader}; |
| @@ -11,7 +11,7 @@ quick_error! { · 5 unmodified lines |
| 11 | 11 | Corrupt(msg: String, path: PathBuf) { |
| 12 | 12 | display("{}", msg) |
| 13 | 13 | } |
| 14 | | − GraphFile(err: graph_file::Error, path: PathBuf) { |
| 14 | + File(err: file::Error, path: PathBuf) { |
| 15 | 15 | display("{}", path.display()) |
| 16 | 16 | source(err) |
| 17 | 17 | } |
| @@ -25,7 +25,7 @@ quick_error! { · 7 unmodified lines |
| 25 | 25 | ) |
| 26 | 26 | } |
| 27 | 27 | Io(err: std::io::Error, path: PathBuf) { |
| 28 | | − display("Could not open commit-graph graph_file at '{}'", path.display()) |
| 28 | + display("Could not open commit-graph file at '{}'", path.display()) |
| 29 | 29 | source(err) |
| 30 | 30 | } |
| 31 | 31 | TooManyCommits(num_commits: u64) { |
| @@ -46,7 +46,7 @@ impl Graph { · 14 unmodified lines |
| 46 | 46 | |
| 47 | 47 | pub fn from_single_file(info_dir: impl AsRef<Path>) -> Result<Self, Error> { |
| 48 | 48 | let single_graph_file = info_dir.as_ref().join("commit-graph"); |
| 49 | | − let file = GraphFile::at(&single_graph_file).map_err(|e| Error::GraphFile(e, single_graph_file.clone()))?; |
| 49 | + let file = File::at(&single_graph_file).map_err(|e| Error::File(e, single_graph_file.clone()))?; |
| 50 | 50 | Self::new(vec![file]) |
| 51 | 51 | } |
| 52 | 52 | |
| @@ -54,17 +54,17 @@ impl Graph { · 1 unmodified line |
| 54 | 54 | let commit_graphs_dir = commit_graphs_dir.as_ref(); |
| 55 | 55 | let chain_file_path = commit_graphs_dir.join("commit-graph-chain"); |
| 56 | 56 | let chain_file = std::fs::File::open(&chain_file_path).map_err(|e| Error::Io(e, chain_file_path.clone()))?; |
| 57 | | − let mut files: Vec<GraphFile> = Vec::new(); |
| 57 | + let mut files: Vec<File> = Vec::new(); |
| 58 | 58 | for line in BufReader::new(chain_file).lines() { |
| 59 | 59 | let line = line.map_err(|e| Error::Io(e, chain_file_path.clone()))?; |
| 60 | 60 | let graph_filename = format!("graph-{}.graph", line); |
| 61 | 61 | let graph_file_path = commit_graphs_dir.join(graph_filename); |
| 62 | | − files.push(GraphFile::at(&graph_file_path).map_err(|e| Error::GraphFile(e, graph_file_path.clone()))?); |
| 62 | + files.push(File::at(&graph_file_path).map_err(|e| Error::File(e, graph_file_path.clone()))?); |
| 63 | 63 | } |
| 64 | 64 | Self::new(files) |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | | − pub fn new(files: Vec<GraphFile>) -> Result<Self, Error> { |
| 67 | + pub fn new(files: Vec<File>) -> Result<Self, Error> { |
| 68 | 68 | let num_commits: u64 = files.iter().map(|f| f.num_commits() as u64).sum(); |
| 69 | 69 | if num_commits > MAX_COMMITS as u64 { |
| 70 | 70 | return Err(Error::TooManyCommits(num_commits)); |