History

[commitgraph] Rename GraphFile -> File.

Conor Davis committed 6 years ago

Commit f4518221 parent d8c20078 files · +42 −42Browse files

Showing the changes to git-commitgraph/src/graph (3 of 8 files). Show all

Unified · Split

3 files
  1. git-commitgraph/src/graph/access.rs +3 −3
  2. git-commitgraph/src/graph/init.rs +8 −8
  3. git-commitgraph/src/graph/mod.rs +2 −2
git-commitgraph/src/graph/access.rs+3−3
@@ -1,5 +1,5 @@
1+use crate::file::{File, LexPosition};
12 use crate::graph::GraphPosition;
2−use crate::graph_file::{GraphFile, LexPosition};
33 use crate::{Commit, Graph};
44 use git_object::borrowed;
55
@@ -72,12 +72,12 @@ impl Graph { · 66 unmodified lines
7272 }
7373
7474 struct LookupByIdResult<'a> {
75− pub file: &'a GraphFile,
75+ pub file: &'a File,
7676 pub graph_pos: GraphPosition,
7777 pub lex_pos: LexPosition,
7878 }
7979
8080 struct LookupByPositionResult<'a> {
81− pub file: &'a GraphFile,
81+ pub file: &'a File,
8282 pub lex_pos: LexPosition,
8383 }
git-commitgraph/src/graph/init.rs+8−8
@@ -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};
33 use git_object::HashKind;
44 use quick_error::quick_error;
55 use std::io::{BufRead, BufReader};
@@ -11,7 +11,7 @@ quick_error! { · 5 unmodified lines
1111 Corrupt(msg: String, path: PathBuf) {
1212 display("{}", msg)
1313 }
14− GraphFile(err: graph_file::Error, path: PathBuf) {
14+ File(err: file::Error, path: PathBuf) {
1515 display("{}", path.display())
1616 source(err)
1717 }
@@ -25,7 +25,7 @@ quick_error! { · 7 unmodified lines
2525 )
2626 }
2727 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())
2929 source(err)
3030 }
3131 TooManyCommits(num_commits: u64) {
@@ -46,7 +46,7 @@ impl Graph { · 14 unmodified lines
4646
4747 pub fn from_single_file(info_dir: impl AsRef<Path>) -> Result<Self, Error> {
4848 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()))?;
5050 Self::new(vec![file])
5151 }
5252
@@ -54,17 +54,17 @@ impl Graph { · 1 unmodified line
5454 let commit_graphs_dir = commit_graphs_dir.as_ref();
5555 let chain_file_path = commit_graphs_dir.join("commit-graph-chain");
5656 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();
5858 for line in BufReader::new(chain_file).lines() {
5959 let line = line.map_err(|e| Error::Io(e, chain_file_path.clone()))?;
6060 let graph_filename = format!("graph-{}.graph", line);
6161 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()))?);
6363 }
6464 Self::new(files)
6565 }
6666
67− pub fn new(files: Vec<GraphFile>) -> Result<Self, Error> {
67+ pub fn new(files: Vec<File>) -> Result<Self, Error> {
6868 let num_commits: u64 = files.iter().map(|f| f.num_commits() as u64).sum();
6969 if num_commits > MAX_COMMITS as u64 {
7070 return Err(Error::TooManyCommits(num_commits));
git-commitgraph/src/graph/mod.rs+2−2
@@ -1,7 +1,7 @@
11 mod access;
22 mod init;
33
4−use crate::graph_file::GraphFile;
4+use crate::file::File;
55 use std::fmt::{Display, Formatter};
66
77 /// A complete commit graph.
@@ -10,7 +10,7 @@ use std::fmt::{Display, Formatter}; · 2 unmodified lines
1010 /// may come from one or more `objects/info/commit-graphs/graph-*.graph` files. These files are
1111 /// generated via `git commit-graph write ...` commands.
1212 pub struct Graph {
13− files: Vec<GraphFile>,
13+ files: Vec<File>,
1414 }
1515
1616 #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]