@@ -39,30 +39,6 @@ struct DiffCommitEntry {
39
39
pub base_entry : Option < CommitEntry > ,
40
40
}
41
41
42
- /// Get a String representation of a diff between two commits given a file
43
- pub fn diff_one (
44
- repo : & LocalRepository ,
45
- original : & Commit ,
46
- compare : & Commit ,
47
- path : impl AsRef < Path > ,
48
- ) -> Result < String , OxenError > {
49
- let base_path = get_version_file_from_commit ( repo, original, & path) ?;
50
- let head_path = get_version_file_from_commit ( repo, compare, & path) ?;
51
- diff_files ( base_path, head_path)
52
- }
53
-
54
- /// Compare a file between commits
55
- pub fn diff_one_2 (
56
- repo : & LocalRepository ,
57
- original : & Commit ,
58
- compare : & Commit ,
59
- path : impl AsRef < Path > ,
60
- ) -> Result < GenericDiff , OxenError > {
61
- let base_path = get_version_file_from_commit ( repo, original, & path) ?;
62
- let head_path = get_version_file_from_commit ( repo, compare, & path) ?;
63
- diff_files_2 ( base_path, head_path)
64
- }
65
-
66
42
pub fn get_version_file_from_commit (
67
43
repo : & LocalRepository ,
68
44
commit : & Commit ,
@@ -101,110 +77,6 @@ pub fn get_version_file_from_commit_id(
101
77
Ok ( util:: fs:: version_path ( repo, & entry) )
102
78
}
103
79
104
- pub fn diff_files (
105
- original : impl AsRef < Path > ,
106
- compare : impl AsRef < Path > ,
107
- ) -> Result < String , OxenError > {
108
- let original = original. as_ref ( ) ;
109
- let compare = compare. as_ref ( ) ;
110
- if util:: fs:: is_tabular ( original) && util:: fs:: is_tabular ( compare) {
111
- let tabular_diff = diff_tabular ( original, compare) ?;
112
- return Ok ( tabular_diff. to_string ( ) ) ;
113
- } else if util:: fs:: is_utf8 ( original) && util:: fs:: is_utf8 ( compare) {
114
- return diff_utf8 ( original, compare) ;
115
- }
116
- Err ( OxenError :: basic_str ( format ! (
117
- "Diff not supported for files: {original:?} and {compare:?}"
118
- ) ) )
119
- }
120
-
121
- // TODO: this should be the one that is returned instead of a string
122
- pub fn diff_files_2 (
123
- original : impl AsRef < Path > ,
124
- compare : impl AsRef < Path > ,
125
- ) -> Result < GenericDiff , OxenError > {
126
- let original = original. as_ref ( ) ;
127
- let compare = compare. as_ref ( ) ;
128
- if util:: fs:: is_tabular ( original) && util:: fs:: is_tabular ( compare) {
129
- // TODO: consolidate TabularDiff and DataFrameDiff
130
- // let tabular_diff = diff_tabular(original, compare)?;
131
- // return Ok(GenericDiff::TabularDiff(tabular_diff));
132
- }
133
- Err ( OxenError :: basic_str ( format ! (
134
- "Diff not supported for files: {original:?} and {compare:?}"
135
- ) ) )
136
- }
137
-
138
- pub fn diff_utf8 (
139
- original : impl AsRef < Path > ,
140
- compare : impl AsRef < Path > ,
141
- ) -> Result < String , OxenError > {
142
- let original = original. as_ref ( ) ;
143
- let compare = compare. as_ref ( ) ;
144
- let original_data = util:: fs:: read_from_path ( original) ?;
145
- let compare_data = util:: fs:: read_from_path ( compare) ?;
146
- let Changeset { diffs, .. } = Changeset :: new ( & original_data, & compare_data, "\n " ) ;
147
-
148
- let mut outputs: Vec < String > = vec ! [ ] ;
149
- for diff in diffs {
150
- match diff {
151
- Difference :: Same ( ref x) => {
152
- for split in x. split ( '\n' ) {
153
- outputs. push ( format ! ( " {split}\n " ) . normal ( ) . to_string ( ) ) ;
154
- }
155
- }
156
- Difference :: Add ( ref x) => {
157
- for split in x. split ( '\n' ) {
158
- outputs. push ( format ! ( "+{split}\n " ) . green ( ) . to_string ( ) ) ;
159
- }
160
- }
161
- Difference :: Rem ( ref x) => {
162
- for split in x. split ( '\n' ) {
163
- outputs. push ( format ! ( "-{split}\n " ) . red ( ) . to_string ( ) ) ;
164
- }
165
- }
166
- }
167
- }
168
-
169
- Ok ( outputs. join ( "" ) )
170
- }
171
-
172
- pub fn diff_tabular (
173
- base_path : impl AsRef < Path > ,
174
- head_path : impl AsRef < Path > ,
175
- ) -> Result < DataFrameDiff , OxenError > {
176
- let base_path = base_path. as_ref ( ) ;
177
- let head_path = head_path. as_ref ( ) ;
178
- // Make sure files exist
179
- if !base_path. exists ( ) {
180
- return Err ( OxenError :: entry_does_not_exist ( base_path) ) ;
181
- }
182
-
183
- if !head_path. exists ( ) {
184
- return Err ( OxenError :: entry_does_not_exist ( head_path) ) ;
185
- }
186
-
187
- // Read DFs and get schemas
188
- let base_df = tabular:: read_df ( base_path, DFOpts :: empty ( ) ) ?;
189
- let head_df = tabular:: read_df ( head_path, DFOpts :: empty ( ) ) ?;
190
- let base_schema = Schema :: from_polars ( & base_df. schema ( ) ) ;
191
- let head_schema = Schema :: from_polars ( & head_df. schema ( ) ) ;
192
-
193
- log:: debug!(
194
- "Original df {} {base_path:?}\n {base_df:?}" ,
195
- base_schema. hash
196
- ) ;
197
- log:: debug!( "Compare df {} {head_path:?}\n {head_df:?}" , head_schema. hash) ;
198
-
199
- // If schemas don't match, figure out which columns are different
200
- if base_schema. hash != head_schema. hash {
201
- compute_new_columns_from_paths ( base_path, head_path, & base_schema, & head_schema)
202
- } else {
203
- log:: debug!( "Computing diff for {base_path:?} to {head_path:?}" ) ;
204
- compute_new_rows ( & base_df, & head_df, & base_schema)
205
- }
206
- }
207
-
208
80
pub fn count_added_rows ( base_df : DataFrame , head_df : DataFrame ) -> Result < usize , OxenError > {
209
81
// Hash the rows
210
82
let base_df = tabular:: df_hash_rows ( base_df) ?;
0 commit comments