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 @@
1use crate::file::{File, LexPosition};
1use crate::graph::GraphPosition;2use crate::graph::GraphPosition;
2use crate::graph_file::{GraphFile, LexPosition};
3use crate::{Commit, Graph};3use crate::{Commit, Graph};
4use git_object::borrowed;4use git_object::borrowed;
5 5
@@ -72,12 +72,12 @@ impl Graph { · 66 unmodified lines
72}72}
73 73
74struct LookupByIdResult<'a> {74struct LookupByIdResult<'a> {
75 pub file: &'a GraphFile,75 pub file: &'a File,
76 pub graph_pos: GraphPosition,76 pub graph_pos: GraphPosition,
77 pub lex_pos: LexPosition,77 pub lex_pos: LexPosition,
78}78}
79 79
80struct LookupByPositionResult<'a> {80struct LookupByPositionResult<'a> {
81 pub file: &'a GraphFile,81 pub file: &'a File,
82 pub lex_pos: LexPosition,82 pub lex_pos: LexPosition,
83}83}
git-commitgraph/src/graph/init.rs+8−8
@@ -1,5 +1,5 @@
1use crate::graph_file::GraphFile;1use crate::file::File;
2use crate::{graph_file, Graph, MAX_COMMITS};2use crate::{file, Graph, MAX_COMMITS};
3use git_object::HashKind;3use git_object::HashKind;
4use quick_error::quick_error;4use quick_error::quick_error;
5use std::io::{BufRead, BufReader};5use std::io::{BufRead, BufReader};
@@ -11,7 +11,7 @@ quick_error! { · 5 unmodified lines
11 Corrupt(msg: String, path: PathBuf) {11 Corrupt(msg: String, path: PathBuf) {
12 display("{}", msg)12 display("{}", msg)
13 }13 }
14 GraphFile(err: graph_file::Error, path: PathBuf) {14 File(err: file::Error, path: PathBuf) {
15 display("{}", path.display())15 display("{}", path.display())
16 source(err)16 source(err)
17 }17 }
@@ -25,7 +25,7 @@ quick_error! { · 7 unmodified lines
25 )25 )
26 }26 }
27 Io(err: std::io::Error, path: PathBuf) {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 source(err)29 source(err)
30 }30 }
31 TooManyCommits(num_commits: u64) {31 TooManyCommits(num_commits: u64) {
@@ -46,7 +46,7 @@ impl Graph { · 14 unmodified lines
46 46
47 pub fn from_single_file(info_dir: impl AsRef<Path>) -> Result<Self, Error> {47 pub fn from_single_file(info_dir: impl AsRef<Path>) -> Result<Self, Error> {
48 let single_graph_file = info_dir.as_ref().join("commit-graph");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 Self::new(vec![file])50 Self::new(vec![file])
51 }51 }
52 52
@@ -54,17 +54,17 @@ impl Graph { · 1 unmodified line
54 let commit_graphs_dir = commit_graphs_dir.as_ref();54 let commit_graphs_dir = commit_graphs_dir.as_ref();
55 let chain_file_path = commit_graphs_dir.join("commit-graph-chain");55 let chain_file_path = commit_graphs_dir.join("commit-graph-chain");
56 let chain_file = std::fs::File::open(&chain_file_path).map_err(|e| Error::Io(e, chain_file_path.clone()))?;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 for line in BufReader::new(chain_file).lines() {58 for line in BufReader::new(chain_file).lines() {
59 let line = line.map_err(|e| Error::Io(e, chain_file_path.clone()))?;59 let line = line.map_err(|e| Error::Io(e, chain_file_path.clone()))?;
60 let graph_filename = format!("graph-{}.graph", line);60 let graph_filename = format!("graph-{}.graph", line);
61 let graph_file_path = commit_graphs_dir.join(graph_filename);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 Self::new(files)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 let num_commits: u64 = files.iter().map(|f| f.num_commits() as u64).sum();68 let num_commits: u64 = files.iter().map(|f| f.num_commits() as u64).sum();
69 if num_commits > MAX_COMMITS as u64 {69 if num_commits > MAX_COMMITS as u64 {
70 return Err(Error::TooManyCommits(num_commits));70 return Err(Error::TooManyCommits(num_commits));
git-commitgraph/src/graph/mod.rs+2−2
@@ -1,7 +1,7 @@
1mod access;1mod access;
2mod init;2mod init;
3 3
4use crate::graph_file::GraphFile;4use crate::file::File;
5use std::fmt::{Display, Formatter};5use std::fmt::{Display, Formatter};
6 6
7/// A complete commit graph.7/// A complete commit graph.
@@ -10,7 +10,7 @@ use std::fmt::{Display, Formatter}; · 2 unmodified lines
10/// may come from one or more `objects/info/commit-graphs/graph-*.graph` files. These files are10/// may come from one or more `objects/info/commit-graphs/graph-*.graph` files. These files are
11/// generated via `git commit-graph write ...` commands.11/// generated via `git commit-graph write ...` commands.
12pub struct Graph {12pub struct Graph {
13 files: Vec<GraphFile>,13 files: Vec<File>,
14}14}
15 15
16#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]16#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]