-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,157 additions
and
965 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
//! For using text diffs, please have a look at the [`imara-diff` documentation](https://docs.rs/imara-diff), | ||
//! maintained by [Pascal Kuthe](https://github.com/pascalkuthe). | ||
//! | ||
//! | ||
/// Information about the diff performed to detect similarity. | ||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] | ||
pub struct DiffLineStats { | ||
/// The amount of lines to remove from the source to get to the destination. | ||
pub removals: u32, | ||
/// The amount of lines to add to the source to get to the destination. | ||
pub insertions: u32, | ||
/// The amount of lines of the previous state, in the source. | ||
pub before: u32, | ||
/// The amount of lines of the new state, in the destination. | ||
pub after: u32, | ||
} | ||
|
||
pub use imara_diff::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use crate::Rewrites; | ||
|
||
/// Types related to the rename tracker for renames, rewrites and copies. | ||
pub mod tracker; | ||
|
||
/// A type to retain state related to an ongoing tracking operation to retain sets of interesting changes | ||
/// of which some are retained to at a later stage compute the ones that seem to be renames or copies. | ||
pub struct Tracker<T> { | ||
/// The tracked items thus far, which will be used to determine renames/copies and rewrites later. | ||
items: Vec<tracker::Item<T>>, | ||
/// A place to store all paths in to reduce amount of allocations. | ||
path_backing: Vec<u8>, | ||
/// A buffer for use when fetching objects for similarity tests. | ||
buf1: Vec<u8>, | ||
/// Another buffer for use when fetching objects for similarity tests. | ||
buf2: Vec<u8>, | ||
/// How to track copies and/or rewrites. | ||
rewrites: Rewrites, | ||
/// The diff algorithm to use when checking for similarity. | ||
diff_algo: crate::blob::Algorithm, | ||
} | ||
|
||
/// Determine in which set of files to search for copies. | ||
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] | ||
pub enum CopySource { | ||
/// Find copies from the set of modified files only. | ||
#[default] | ||
FromSetOfModifiedFiles, | ||
/// Find copies from the set of modified files, as well as all files known to the source (i.e. previous state of the tree). | ||
/// | ||
/// This can be an expensive operation as it scales exponentially with the total amount of files in the set. | ||
FromSetOfModifiedFilesAndAllSources, | ||
} | ||
|
||
/// Under which circumstances we consider a file to be a copy. | ||
#[derive(Debug, Copy, Clone, PartialEq)] | ||
pub struct Copies { | ||
/// The set of files to search when finding the source of copies. | ||
pub source: CopySource, | ||
/// Equivalent to [`Rewrites::percentage`], but used for copy tracking. | ||
/// | ||
/// Useful to have similarity-based rename tracking and cheaper copy tracking. | ||
pub percentage: Option<f32>, | ||
} | ||
|
||
impl Default for Copies { | ||
fn default() -> Self { | ||
Copies { | ||
source: CopySource::default(), | ||
percentage: Some(0.5), | ||
} | ||
} | ||
} | ||
|
||
/// Information collected while handling rewrites of files which may be tracked. | ||
#[derive(Default, Clone, Copy, Debug, PartialEq)] | ||
pub struct Outcome { | ||
/// The options used to guide the rewrite tracking. Either fully provided by the caller or retrieved from git configuration. | ||
pub options: Rewrites, | ||
/// The amount of similarity checks that have been conducted to find renamed files and potentially copies. | ||
pub num_similarity_checks: usize, | ||
/// Set to the amount of worst-case rename permutations we didn't search as our limit didn't allow it. | ||
pub num_similarity_checks_skipped_for_rename_tracking_due_to_limit: usize, | ||
/// Set to the amount of worst-case copy permutations we didn't search as our limit didn't allow it. | ||
pub num_similarity_checks_skipped_for_copy_tracking_due_to_limit: usize, | ||
} | ||
|
||
/// The default settings for rewrites according to the git configuration defaults. | ||
impl Default for Rewrites { | ||
fn default() -> Self { | ||
Rewrites { | ||
copies: None, | ||
percentage: Some(0.5), | ||
limit: 1000, | ||
} | ||
} | ||
} |
Oops, something went wrong.