Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–103 unchanged (103 lines)
104 /// `sample.csv` never clobbers a promotion that already happened.
105 promoted_to: String,
106 /// Which research dataset (tiny/small/full) this row was sampled from - see `Args::dataset`.
107 /// Carried through unchanged on every re-run, same as `promoted_to`: a row's provenance
108 /// doesn't change just because a later run happens to target a different `--repos-dir`.
109 dataset: String,
110}
111
112type SampleKey = (String, String, String);
113
114/// Historical default for any row read from a sample.csv written before provenance tracking
115/// existed - every one of those was in fact sampled from the small research checkout (the only
116/// one available when they were added), so this is a real fallback value, not a placeholder.
117const LEGACY_DATASET: &str = "small";
118
119fn default_output_path() -> PathBuf {
120 PathBuf::from(env!("CARGO_MANIFEST_DIR"))
121 .join("src")
122 .join("test")
123 .join("data")
124 .join("sample.csv")
…lines 125–142 unchanged (18 lines)
143 }
144
145 let mut reader = csv::Reader::from_path(path)?;
146 let mut rows = Vec::new();
147 for record in reader.records() {
148 let record = record?;
149 rows.push(Row {
150 language: record[0].to_string(),
151 repository: record[1].to_string(),
152 commit: record[2].to_string(),
153 path: record[3].to_string(),
154 promoted_to: record.get(4).unwrap_or("").to_string(),
155 dataset: record.get(5).unwrap_or(LEGACY_DATASET).to_string(),
156 });
157 }
158 Ok(rows)
159}
160
161fn main() -> Result<()> {
162 let args = Args::parse();
…lines 163–286 unchanged (124 lines)
287 language: language.clone(),
288 repository: repository_name.to_string(),
289 commit: id.to_string(),
290 path,
291 promoted_to: String::new(),
292 dataset: dataset.to_string(),
293 };
294 reservoirs
295 .entry(language)
296 .or_default()
297 .offer(row, capacity, rng);
298
299 Ok(())
…lines 300–325 unchanged (26 lines)
326 "language",
327 "repository",
328 "commit",
329 "path",
330 "promoted_to",
331 "dataset",
332 ])?;
333 for row in &rows {
334 writer.write_record([
335 &row.language,
336 &row.repository,
337 &row.commit,
338 &row.path,
339 &row.promoted_to,
340 &row.dataset,
341 ])?;
342 }
343 writer.flush()?;
344 Ok(())
345}
346
347#[cfg(test)]
…lines 348–437 unchanged (90 lines)

After

…lines 1–103 unchanged (103 lines)
104 /// `sample.csv` never clobbers a promotion that already happened.
105 promoted_to: String,
106 /// Which research dataset (tiny/small/full) this row was sampled from - see `Args::dataset`.
107 /// Carried through unchanged on every re-run, same as `promoted_to`: a row's provenance
108 /// doesn't change just because a later run happens to target a different `--repos-dir`.
109 dataset: String,
110 /// One of `SAMPLED`/`PROMOTED`/`REJECTED` - `human_solver` moves a row from `SAMPLED` to
111 /// whichever of the other two applies when the sample is triaged (`s` to promote, `R` to
112 /// reject); this tool never sets anything but `SAMPLED` on a freshly-sampled row.
113 status: String,
114 /// Why this row was rejected instead of promoted, verbatim from `human_solver`'s reject
115 /// prompt. Empty unless `status` is `REJECTED`.
116 rejection_reason: String,
117}
118
119type SampleKey = (String, String, String);
120
121/// Historical default for any row read from a sample.csv written before provenance tracking
122/// existed - every one of those was in fact sampled from the small research checkout (the only
123/// one available when they were added), so this is a real fallback value, not a placeholder.
124const LEGACY_DATASET: &str = "small";
125
126/// Backfills `status` for a row read from a sample.csv written before that column existed: a
127/// non-empty `promoted_to` means it was already promoted, otherwise it's just sitting there
128/// unsampled -- there's no way a pre-existing row could be `REJECTED`, since rejection didn't
129/// exist yet either.
130fn default_status(promoted_to: &str) -> &'static str {
131 if promoted_to.is_empty() {
132 "SAMPLED"
133 } else {
134 "PROMOTED"
135 }
136}
137
138fn default_output_path() -> PathBuf {
139 PathBuf::from(env!("CARGO_MANIFEST_DIR"))
140 .join("src")
141 .join("test")
142 .join("data")
…lines 143–161 unchanged (19 lines)
162 }
163
164 let mut reader = csv::Reader::from_path(path)?;
165 let mut rows = Vec::new();
166 for record in reader.records() {
167 let record = record?;
168 let promoted_to = record.get(4).unwrap_or("").to_string();
169 let status = match record.get(6) {
170 Some(status) if !status.is_empty() => status.to_string(),
171 _ => default_status(&promoted_to).to_string(),
172 };
173 rows.push(Row {
174 language: record[0].to_string(),
175 repository: record[1].to_string(),
176 commit: record[2].to_string(),
177 path: record[3].to_string(),
178 promoted_to,
179 dataset: record.get(5).unwrap_or(LEGACY_DATASET).to_string(),
180 status,
181 rejection_reason: record.get(7).unwrap_or("").to_string(),
182 });
183 }
184 Ok(rows)
185}
186
187fn main() -> Result<()> {
…lines 188–312 unchanged (125 lines)
313 language: language.clone(),
314 repository: repository_name.to_string(),
315 commit: id.to_string(),
316 path,
317 promoted_to: String::new(),
318 dataset: dataset.to_string(),
319 status: "SAMPLED".to_string(),
320 rejection_reason: String::new(),
321 };
322 reservoirs
323 .entry(language)
324 .or_default()
325 .offer(row, capacity, rng);
326
…lines 327–353 unchanged (27 lines)
354 "language",
355 "repository",
356 "commit",
357 "path",
358 "promoted_to",
359 "dataset",
360 "status",
361 "rejection_reason",
362 ])?;
363 for row in &rows {
364 writer.write_record([
365 &row.language,
366 &row.repository,
367 &row.commit,
368 &row.path,
369 &row.promoted_to,
370 &row.dataset,
371 &row.status,
372 &row.rejection_reason,
373 ])?;
374 }
375 writer.flush()?;
376 Ok(())
377}
378
…lines 379–469 unchanged (91 lines)

Before

source_file
block_comment
/* "/*"
*/ "*/"
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Samples real (repository, commit, path) pointers to single-"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " for hand-curated unit tests under `src/test/data/diffs/`. U"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " tool is meant to be run repeatedly against different checko"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " research datasets): it reads whatever is already in `src/te"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " each language to exactly `--count` samples rather than star"...
use_declaration
use "use"
scoped_identifier
identifier "anyhow"
:: "::"
identifier "Result"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "clap"
:: "::"
identifier "Parser"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "git2"
:: "::"
identifier "Delta"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "rand"
:: "::"
identifier "SeedableRng"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "rand"
:: "::"
identifier "rngs"
:: "::"
identifier "StdRng"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
identifier "std"
:: "::"
identifier "collections"
:: "::"
use_list
{ "{"
identifier "HashMap"
, ","
identifier "HashSet"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "std"
:: "::"
identifier "fs"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
identifier "std"
:: "::"
identifier "path"
:: "::"
use_list
{ "{"
identifier "Path"
, ","
identifier "PathBuf"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "code"
:: "::"
identifier "language"
:: "::"
use_list
{ "{"
identifier "language_for_path"
, ","
identifier "to_treesitter"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "codediff"
:: "::"
identifier "metadata"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "stats"
:: "::"
identifier "filesystem"
:: "::"
use_list
{ "{"
identifier "find_git_repositories"
, ","
identifier "for_each_repository"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "stats"
:: "::"
identifier "git"
:: "::"
use_list
{ "{"
identifier "text_len_if_in_range"
, ","
identifier "walk_single_parent_commit_diffs"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "stats"
:: "::"
identifier "sampling"
:: "::"
identifier "Reservoir"
; ";"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
const_item
const "const"
identifier "MIN_BYTES"
: ":"
primitive_type "usize"
= "="
integer_literal "1"
; ";"
const_item
const "const"
identifier "MAX_BYTES"
: ":"
primitive_type "usize"
= "="
binary_expression
integer_literal "1024"
* "*"
integer_literal "1024"
; ";"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Parser"
) ")"
] "]"
struct_item (+256 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A pointer to a (before, after) code pair: the actual conten"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " checkout, not in this tool's output, so only enough is reco"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Reconstruction contract: before = blob at `path` in `commit"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " after = blob at `path` in `commit`'s tree. Renames are deli"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `sample_repository`), so `path` always names both sides.\n"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Clone"
, ","
identifier "Eq"
, ","
identifier "PartialEq"
) ")"
] "]"
struct_item
struct "struct"
type_identifier "Row"
field_declaration_list
{ "{"
field_declaration
field_identifier "language"
: ":"
type_identifier "String"
, ","
field_declaration
field_identifier "repository"
: ":"
type_identifier "String"
, ","
field_declaration
field_identifier "commit"
: ":"
type_identifier "String"
, ","
field_declaration
field_identifier "path"
: ":"
type_identifier "String"
, ","
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Name of the `src/test/data/diffs/` test case this row was p"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `human_solver`, not by this tool). Carried through unchange"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `sample.csv` never clobbers a promotion that already happen"...
field_declaration
field_identifier "promoted_to"
: ":"
type_identifier "String"
, ","
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Which research dataset (tiny/small/full) this row was sampl"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Carried through unchanged on every re-run, same as `promote"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " doesn't change just because a later run happens to target a"...
field_declaration
field_identifier "dataset"
: ":"
type_identifier "String"
, ","
} "}"
type_item
type "type"
type_identifier "SampleKey"
= "="
tuple_type
( "("
type_identifier "String"
, ","
type_identifier "String"
, ","
type_identifier "String"
) ")"
; ";"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Historical default for any row read from a sample.csv writt"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " existed - every one of those was in fact sampled from the s"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " one available when they were added), so this is a real fall"...
const_item
const "const"
identifier "LEGACY_DATASET"
: ":"
reference_type
& "&"
primitive_type "str"
= "="
string_literal
" "\""
string_content "small"
" "\""
; ";"
function_item (+73 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `--dataset`'s auto-inference: `repos_dir`'s parent director"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `.../research/<dataset>/repositories` convention `--repos-d"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `materialize_test_diffs`'s `DEFAULT_REPO_ROOTS` already use"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " doesn't follow that convention (e.g. a bare repository path"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " callers should require `--dataset` explicitly in that case "...
function_item (+68 nodes collapsed)
function_item
fn "fn"
identifier "read_existing_rows"
parameters
( "("
parameter
identifier "path"
: ":"
reference_type
& "&"
type_identifier "Path"
) ")"
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
generic_type
type_identifier "Vec"
type_arguments
< "<"
type_identifier "Row"
> ">"
> ">"
block
{ "{"
expression_statement (+33 nodes collapsed)
let_declaration
let "let"
mutable_specifier "mut"
identifier "reader"
= "="
try_expression
call_expression
scoped_identifier
scoped_identifier
identifier "csv"
:: "::"
identifier "Reader"
:: "::"
identifier "from_path"
arguments
( "("
identifier "path"
) ")"
? "?"
; ";"
let_declaration
let "let"
mutable_specifier "mut"
identifier "rows"
= "="
call_expression
scoped_identifier
identifier "Vec"
:: "::"
identifier "new"
arguments
( "("
) ")"
; ";"
expression_statement
for_expression
for "for"
identifier "record"
in "in"
call_expression
field_expression
identifier "reader"
. "."
field_identifier "records"
arguments
( "("
) ")"
block
{ "{"
let_declaration
let "let"
identifier "record"
= "="
try_expression
identifier "record"
? "?"
; ";"
expression_statement
call_expression
field_expression
identifier "rows"
. "."
field_identifier "push"
arguments
( "("
struct_expression
type_identifier "Row"
field_initializer_list
{ "{"
field_initializer
field_identifier "language"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "0"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "repository"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "1"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "commit"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "2"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "path"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "3"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "promoted_to"
: ":"
call_expression (+26 nodes collapsed)
, ","
field_initializer (+27 nodes collapsed)
, ","
} "}"
) ")"
; ";"
} "}"
call_expression
identifier "Ok"
arguments
( "("
identifier "rows"
) ")"
} "}"
function_item (+628 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Walks every non-merge commit in the repository and offers e"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " (commit, path) to the reservoir for its language, topping u"...
attribute_item
# "#"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "too_many_arguments"
) ")"
] "]"
function_item
fn "fn"
identifier "sample_repository"
parameters (+115 nodes collapsed)
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
unit_type
( "("
) ")"
> ">"
block
{ "{"
call_expression
identifier "walk_single_parent_commit_diffs"
arguments
( "("
identifier "repo_path"
, ","
identifier "max_commits"
, ","
boolean_literal
false "false"
, ","
closure_expression
closure_parameters
| "|"
identifier "repo"
, ","
identifier "id"
, ","
identifier "delta"
| "|"
block
{ "{"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
expression_statement (+32 nodes collapsed)
line_comment
// "//"
expression_statement (+50 nodes collapsed)
let_declaration (+40 nodes collapsed)
expression_statement (+27 nodes collapsed)
let_declaration (+31 nodes collapsed)
line_comment
// "//"
expression_statement (+33 nodes collapsed)
let_declaration
let "let"
identifier "language"
= "="
call_expression
field_expression
identifier "language"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
; ";"
expression_statement (+33 nodes collapsed)
let_declaration
let "let"
identifier "path"
= "="
call_expression
field_expression
call_expression
field_expression
identifier "path"
. "."
field_identifier "to_string_lossy"
arguments
( "("
) ")"
. "."
field_identifier "into_owned"
arguments
( "("
) ")"
; ";"
let_declaration (+34 nodes collapsed)
expression_statement (+29 nodes collapsed)
let_declaration (+35 nodes collapsed)
expression_statement (+64 nodes collapsed)
let_declaration (+71 nodes collapsed)
let_declaration
let "let"
identifier "row"
= "="
struct_expression
type_identifier "Row"
field_initializer_list
{ "{"
field_initializer
field_identifier "language"
: ":"
call_expression
field_expression
identifier "language"
. "."
field_identifier "clone"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "repository"
: ":"
call_expression
field_expression
identifier "repository_name"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "commit"
: ":"
call_expression
field_expression
identifier "id"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
shorthand_field_initializer
identifier "path"
, ","
field_initializer
field_identifier "promoted_to"
: ":"
call_expression
scoped_identifier
identifier "String"
:: "::"
identifier "new"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "dataset"
: ":"
call_expression
field_expression
identifier "dataset"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
} "}"
; ";"
expression_statement (+30 nodes collapsed)
call_expression
identifier "Ok"
arguments
( "("
unit_expression
( "("
) ")"
) ")"
} "}"
) ")"
} "}"
function_item
fn "fn"
identifier "write_csv"
parameters (+37 nodes collapsed)
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
unit_type
( "("
) ")"
> ">"
block
{ "{"
let_declaration
let "let"
mutable_specifier "mut"
identifier "rows"
= "="
identifier "existing_rows"
; ";"
expression_statement (+28 nodes collapsed)
expression_statement (+90 nodes collapsed)
expression_statement (+35 nodes collapsed)
let_declaration
let "let"
mutable_specifier "mut"
identifier "writer"
= "="
try_expression
call_expression
scoped_identifier
scoped_identifier
identifier "csv"
:: "::"
identifier "Writer"
:: "::"
identifier "from_path"
arguments
( "("
identifier "path"
) ")"
? "?"
; ";"
expression_statement
try_expression
call_expression
field_expression
identifier "writer"
. "."
field_identifier "write_record"
arguments
( "("
array_expression
[ "["
string_literal
" "\""
string_content "language"
" "\""
, ","
string_literal
" "\""
string_content "repository"
" "\""
, ","
string_literal
" "\""
string_content "commit"
" "\""
, ","
string_literal
" "\""
string_content "path"
" "\""
, ","
string_literal
" "\""
string_content "promoted_to"
" "\""
, ","
string_literal
" "\""
string_content "dataset"
" "\""
, ","
] "]"
) ")"
? "?"
; ";"
expression_statement
for_expression
for "for"
identifier "row"
in "in"
reference_expression
& "&"
identifier "rows"
block
{ "{"
expression_statement
try_expression
call_expression
field_expression
identifier "writer"
. "."
field_identifier "write_record"
arguments
( "("
array_expression
[ "["
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "language"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "repository"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "commit"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "path"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "promoted_to"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "dataset"
, ","
] "]"
) ")"
? "?"
; ";"
} "}"
expression_statement
try_expression
call_expression
field_expression
identifier "writer"
. "."
field_identifier "flush"
arguments
( "("
) ")"
? "?"
; ";"
call_expression
identifier "Ok"
arguments
( "("
unit_expression
( "("
) ")"
) ")"
} "}"
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "test"
) ")"
] "]"
mod_item (+925 nodes collapsed)

After

source_file
block_comment
/* "/*"
*/ "*/"
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Samples real (repository, commit, path) pointers to single-"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " for hand-curated unit tests under `src/test/data/diffs/`. U"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " tool is meant to be run repeatedly against different checko"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " research datasets): it reads whatever is already in `src/te"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " each language to exactly `--count` samples rather than star"...
use_declaration
use "use"
scoped_identifier
identifier "anyhow"
:: "::"
identifier "Result"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "clap"
:: "::"
identifier "Parser"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "git2"
:: "::"
identifier "Delta"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "rand"
:: "::"
identifier "SeedableRng"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "rand"
:: "::"
identifier "rngs"
:: "::"
identifier "StdRng"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
identifier "std"
:: "::"
identifier "collections"
:: "::"
use_list
{ "{"
identifier "HashMap"
, ","
identifier "HashSet"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "std"
:: "::"
identifier "fs"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
identifier "std"
:: "::"
identifier "path"
:: "::"
use_list
{ "{"
identifier "Path"
, ","
identifier "PathBuf"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "code"
:: "::"
identifier "language"
:: "::"
use_list
{ "{"
identifier "language_for_path"
, ","
identifier "to_treesitter"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "codediff"
:: "::"
identifier "metadata"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "stats"
:: "::"
identifier "filesystem"
:: "::"
use_list
{ "{"
identifier "find_git_repositories"
, ","
identifier "for_each_repository"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "stats"
:: "::"
identifier "git"
:: "::"
use_list
{ "{"
identifier "text_len_if_in_range"
, ","
identifier "walk_single_parent_commit_diffs"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "codediff"
:: "::"
identifier "stats"
:: "::"
identifier "sampling"
:: "::"
identifier "Reservoir"
; ";"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
const_item
const "const"
identifier "MIN_BYTES"
: ":"
primitive_type "usize"
= "="
integer_literal "1"
; ";"
const_item
const "const"
identifier "MAX_BYTES"
: ":"
primitive_type "usize"
= "="
binary_expression
integer_literal "1024"
* "*"
integer_literal "1024"
; ";"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Parser"
) ")"
] "]"
struct_item (+256 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A pointer to a (before, after) code pair: the actual conten"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " checkout, not in this tool's output, so only enough is reco"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Reconstruction contract: before = blob at `path` in `commit"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " after = blob at `path` in `commit`'s tree. Renames are deli"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `sample_repository`), so `path` always names both sides.\n"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Clone"
, ","
identifier "Eq"
, ","
identifier "PartialEq"
) ")"
] "]"
struct_item
struct "struct"
type_identifier "Row"
field_declaration_list
{ "{"
field_declaration
field_identifier "language"
: ":"
type_identifier "String"
, ","
field_declaration
field_identifier "repository"
: ":"
type_identifier "String"
, ","
field_declaration
field_identifier "commit"
: ":"
type_identifier "String"
, ","
field_declaration
field_identifier "path"
: ":"
type_identifier "String"
, ","
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Name of the `src/test/data/diffs/` test case this row was p"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `human_solver`, not by this tool). Carried through unchange"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `sample.csv` never clobbers a promotion that already happen"...
field_declaration
field_identifier "promoted_to"
: ":"
type_identifier "String"
, ","
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Which research dataset (tiny/small/full) this row was sampl"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Carried through unchanged on every re-run, same as `promote"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " doesn't change just because a later run happens to target a"...
field_declaration
field_identifier "dataset"
: ":"
type_identifier "String"
, ","
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " One of `SAMPLED`/`PROMOTED`/`REJECTED` - `human_solver` mov"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " whichever of the other two applies when the sample is triag"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " reject); this tool never sets anything but `SAMPLED` on a f"...
field_declaration
field_identifier "status"
: ":"
type_identifier "String"
, ","
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Why this row was rejected instead of promoted, verbatim fro"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " prompt. Empty unless `status` is `REJECTED`.\n"
field_declaration
field_identifier "rejection_reason"
: ":"
type_identifier "String"
, ","
} "}"
type_item
type "type"
type_identifier "SampleKey"
= "="
tuple_type
( "("
type_identifier "String"
, ","
type_identifier "String"
, ","
type_identifier "String"
) ")"
; ";"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Historical default for any row read from a sample.csv writt"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " existed - every one of those was in fact sampled from the s"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " one available when they were added), so this is a real fall"...
const_item
const "const"
identifier "LEGACY_DATASET"
: ":"
reference_type
& "&"
primitive_type "str"
= "="
string_literal
" "\""
string_content "small"
" "\""
; ";"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Backfills `status` for a row read from a sample.csv written"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " non-empty `promoted_to` means it was already promoted, othe"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " unsampled -- there's no way a pre-existing row could be `RE"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " exist yet either.\n"
function_item
fn "fn"
identifier "default_status"
parameters
( "("
parameter
identifier "promoted_to"
: ":"
reference_type
& "&"
primitive_type "str"
) ")"
-> "->"
reference_type
& "&"
lifetime
' "'"
identifier "static"
primitive_type "str"
block
{ "{"
expression_statement
if_expression
if "if"
call_expression
field_expression
identifier "promoted_to"
. "."
field_identifier "is_empty"
arguments
( "("
) ")"
block
{ "{"
string_literal
" "\""
string_content "SAMPLED"
" "\""
} "}"
else_clause
else "else"
block
{ "{"
string_literal
" "\""
string_content "PROMOTED"
" "\""
} "}"
} "}"
function_item (+73 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `--dataset`'s auto-inference: `repos_dir`'s parent director"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `.../research/<dataset>/repositories` convention `--repos-d"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " `materialize_test_diffs`'s `DEFAULT_REPO_ROOTS` already use"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " doesn't follow that convention (e.g. a bare repository path"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " callers should require `--dataset` explicitly in that case "...
function_item (+68 nodes collapsed)
function_item
fn "fn"
identifier "read_existing_rows"
parameters
( "("
parameter
identifier "path"
: ":"
reference_type
& "&"
type_identifier "Path"
) ")"
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
generic_type
type_identifier "Vec"
type_arguments
< "<"
type_identifier "Row"
> ">"
> ">"
block
{ "{"
expression_statement (+33 nodes collapsed)
let_declaration
let "let"
mutable_specifier "mut"
identifier "reader"
= "="
try_expression
call_expression
scoped_identifier
scoped_identifier
identifier "csv"
:: "::"
identifier "Reader"
:: "::"
identifier "from_path"
arguments
( "("
identifier "path"
) ")"
? "?"
; ";"
let_declaration
let "let"
mutable_specifier "mut"
identifier "rows"
= "="
call_expression
scoped_identifier
identifier "Vec"
:: "::"
identifier "new"
arguments
( "("
) ")"
; ";"
expression_statement
for_expression
for "for"
identifier "record"
in "in"
call_expression
field_expression
identifier "reader"
. "."
field_identifier "records"
arguments
( "("
) ")"
block
{ "{"
let_declaration
let "let"
identifier "record"
= "="
try_expression
identifier "record"
? "?"
; ";"
let_declaration
let "let"
identifier "promoted_to"
= "="
call_expression (+26 nodes collapsed)
; ";"
let_declaration
let "let"
identifier "status"
= "="
match_expression
match "match"
call_expression
field_expression
identifier "record"
. "."
field_identifier "get"
arguments
( "("
integer_literal "6"
) ")"
match_block
{ "{"
match_arm
match_pattern
tuple_struct_pattern
identifier "Some"
( "("
identifier "status"
) ")"
if "if"
unary_expression
! "!"
call_expression
field_expression
identifier "status"
. "."
field_identifier "is_empty"
arguments
( "("
) ")"
=> "=>"
call_expression
field_expression
identifier "status"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
match_arm
match_pattern
_ "_"
=> "=>"
call_expression
field_expression
call_expression
identifier "default_status"
arguments
( "("
reference_expression
& "&"
identifier "promoted_to"
) ")"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
} "}"
; ";"
expression_statement
call_expression
field_expression
identifier "rows"
. "."
field_identifier "push"
arguments
( "("
struct_expression
type_identifier "Row"
field_initializer_list
{ "{"
field_initializer
field_identifier "language"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "0"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "repository"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "1"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "commit"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "2"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "path"
: ":"
call_expression
field_expression
index_expression
identifier "record"
[ "["
integer_literal "3"
] "]"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
shorthand_field_initializer
identifier "promoted_to"
, ","
field_initializer (+27 nodes collapsed)
, ","
shorthand_field_initializer
identifier "status"
, ","
field_initializer
field_identifier "rejection_reason"
: ":"
call_expression
field_expression
call_expression
field_expression
call_expression
field_expression
identifier "record"
. "."
field_identifier "get"
arguments
( "("
integer_literal "7"
) ")"
. "."
field_identifier "unwrap_or"
arguments
( "("
string_literal
" "\""
" "\""
) ")"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
} "}"
) ")"
; ";"
} "}"
call_expression
identifier "Ok"
arguments
( "("
identifier "rows"
) ")"
} "}"
function_item (+628 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Walks every non-merge commit in the repository and offers e"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " (commit, path) to the reservoir for its language, topping u"...
attribute_item
# "#"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "too_many_arguments"
) ")"
] "]"
function_item
fn "fn"
identifier "sample_repository"
parameters (+115 nodes collapsed)
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
unit_type
( "("
) ")"
> ">"
block
{ "{"
call_expression
identifier "walk_single_parent_commit_diffs"
arguments
( "("
identifier "repo_path"
, ","
identifier "max_commits"
, ","
boolean_literal
false "false"
, ","
closure_expression
closure_parameters
| "|"
identifier "repo"
, ","
identifier "id"
, ","
identifier "delta"
| "|"
block
{ "{"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
expression_statement (+32 nodes collapsed)
line_comment
// "//"
expression_statement (+50 nodes collapsed)
let_declaration (+40 nodes collapsed)
expression_statement (+27 nodes collapsed)
let_declaration (+31 nodes collapsed)
line_comment
// "//"
expression_statement (+33 nodes collapsed)
let_declaration
let "let"
identifier "language"
= "="
call_expression
field_expression
identifier "language"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
; ";"
expression_statement (+33 nodes collapsed)
let_declaration
let "let"
identifier "path"
= "="
call_expression
field_expression
call_expression
field_expression
identifier "path"
. "."
field_identifier "to_string_lossy"
arguments
( "("
) ")"
. "."
field_identifier "into_owned"
arguments
( "("
) ")"
; ";"
let_declaration (+34 nodes collapsed)
expression_statement (+29 nodes collapsed)
let_declaration (+35 nodes collapsed)
expression_statement (+64 nodes collapsed)
let_declaration (+71 nodes collapsed)
let_declaration
let "let"
identifier "row"
= "="
struct_expression
type_identifier "Row"
field_initializer_list
{ "{"
field_initializer
field_identifier "language"
: ":"
call_expression
field_expression
identifier "language"
. "."
field_identifier "clone"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "repository"
: ":"
call_expression
field_expression
identifier "repository_name"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "commit"
: ":"
call_expression
field_expression
identifier "id"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
shorthand_field_initializer
identifier "path"
, ","
field_initializer
field_identifier "promoted_to"
: ":"
call_expression
scoped_identifier
identifier "String"
:: "::"
identifier "new"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "dataset"
: ":"
call_expression
field_expression
identifier "dataset"
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "status"
: ":"
call_expression
field_expression
string_literal
" "\""
string_content "SAMPLED"
" "\""
. "."
field_identifier "to_string"
arguments
( "("
) ")"
, ","
field_initializer
field_identifier "rejection_reason"
: ":"
call_expression
scoped_identifier
identifier "String"
:: "::"
identifier "new"
arguments
( "("
) ")"
, ","
} "}"
; ";"
expression_statement (+30 nodes collapsed)
call_expression
identifier "Ok"
arguments
( "("
unit_expression
( "("
) ")"
) ")"
} "}"
) ")"
} "}"
function_item
fn "fn"
identifier "write_csv"
parameters (+37 nodes collapsed)
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
unit_type
( "("
) ")"
> ">"
block
{ "{"
let_declaration
let "let"
mutable_specifier "mut"
identifier "rows"
= "="
identifier "existing_rows"
; ";"
expression_statement (+28 nodes collapsed)
expression_statement (+90 nodes collapsed)
expression_statement (+35 nodes collapsed)
let_declaration
let "let"
mutable_specifier "mut"
identifier "writer"
= "="
try_expression
call_expression
scoped_identifier
scoped_identifier
identifier "csv"
:: "::"
identifier "Writer"
:: "::"
identifier "from_path"
arguments
( "("
identifier "path"
) ")"
? "?"
; ";"
expression_statement
try_expression
call_expression
field_expression
identifier "writer"
. "."
field_identifier "write_record"
arguments
( "("
array_expression
[ "["
string_literal
" "\""
string_content "language"
" "\""
, ","
string_literal
" "\""
string_content "repository"
" "\""
, ","
string_literal
" "\""
string_content "commit"
" "\""
, ","
string_literal
" "\""
string_content "path"
" "\""
, ","
string_literal
" "\""
string_content "promoted_to"
" "\""
, ","
string_literal
" "\""
string_content "dataset"
" "\""
, ","
string_literal
" "\""
string_content "status"
" "\""
, ","
string_literal
" "\""
string_content "rejection_reason"
" "\""
, ","
] "]"
) ")"
? "?"
; ";"
expression_statement
for_expression
for "for"
identifier "row"
in "in"
reference_expression
& "&"
identifier "rows"
block
{ "{"
expression_statement
try_expression
call_expression
field_expression
identifier "writer"
. "."
field_identifier "write_record"
arguments
( "("
array_expression
[ "["
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "language"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "repository"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "commit"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "path"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "promoted_to"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "dataset"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "status"
, ","
reference_expression
& "&"
field_expression
identifier "row"
. "."
field_identifier "rejection_reason"
, ","
] "]"
) ")"
? "?"
; ";"
} "}"
expression_statement
try_expression
call_expression
field_expression
identifier "writer"
. "."
field_identifier "flush"
arguments
( "("
) ")"
? "?"
; ";"
call_expression
identifier "Ok"
arguments
( "("
unit_expression
( "("
) ")"
) ")"
} "}"
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "test"
) ")"
] "]"
mod_item (+925 nodes collapsed)