bugbug 0.0.659__tar.gz → 0.0.661__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bugbug-0.0.659 → bugbug-0.0.661}/PKG-INFO +1 -1
- bugbug-0.0.661/VERSION +1 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/db.py +41 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/repository.py +299 -21
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/test_scheduling.py +47 -1
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/agent.py +12 -19
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/review_context.py +96 -15
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/review_context_schema.py +54 -4
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/commit_classifier.py +6 -2
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/commit_retriever.py +8 -3
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/generate_landings_risk_report.py +6 -1
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/shadow_scheduler_stats.py +8 -2
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/testing_policy_stats.py +6 -1
- bugbug-0.0.659/VERSION +0 -1
- {bugbug-0.0.659 → bugbug-0.0.661}/.gitignore +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/LICENSE +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/bug_features.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/bug_snapshot.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/bugzilla.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/build_platforms.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/code_search/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/code_search/function_search.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/code_search/mozilla.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/code_search/parser.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/code_search/searchfox_api.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/code_search/searchfox_data.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/code_search/searchfox_download.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/commit_features.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/feature_cleanup.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/github.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/issue_features.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/issue_snapshot.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/annotateignore.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/bug_nobug.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/defect_enhancement_task.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/defect_enhancement_task_e.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/defect_enhancement_task_h.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/defect_enhancement_task_p.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/defect_enhancement_task_s.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/regression_bug_nobug.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/regressionrange.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/str.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels/tracking.csv +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/labels.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/model.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/model_calibration.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/accessibility.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/annotate_ignore.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/assignee.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/backout.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/browsername.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/bugtype.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/component.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/component_specific.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/defect.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/defect_enhancement_task.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/devdocneeded.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/fenixcomponent.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/fixtime.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/invalid_compatibility_report.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/needsdiagnosis.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/perf_regression_predictor.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/performancebug.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/qaneeded.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/rcatype.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/regression.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/regressionrange.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/regressor.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/severity.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/spambug.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/stepstoreproduce.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/testconfigdimensions.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/testconfigselect.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/testfailure.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/testselect.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/tracking.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/uplift.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/models/worksforme.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/nlp.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/calibration.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/commit_risk.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/datasets.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/extraction.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/label_policy.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/push_status.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/regression_commits.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/regression_labeling.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/selection_pairs.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/capacity.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/detection.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/metrics.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/optimize.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/splits.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/stats.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/strategies.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/simulation/timeline.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_alerts.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_capacity_background.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_capacity_builds.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_capacity_eligible.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_capacity_labels.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_capacity_pools.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_capacity_workers.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_pushes.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_task_costs.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/sql/perf_task_filter.sql +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/task_costs.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/perf/task_labels.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/phabricator.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/redash.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/rust_code_analysis_server.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/sklearn_utils.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/swarm.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/test_scheduling_features.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/base.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/data_types.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/database.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/langchain_tools.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/prompts.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/protocols.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/scorer.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/code_review/utils.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/comment_matching/agent.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/comment_matching/prompts.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/comment_resolution/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/comment_resolution/agent.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/connection.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/data_types.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/exceptions.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/llms.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/platforms/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/platforms/base.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/platforms/bugzilla.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/platforms/patch_apply.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/platforms/phabricator.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/text.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/core/validators.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/patch_summarization/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/patch_summarization/agent.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/patch_summarization/prompts.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/suggestion_filtering/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/suggestion_filtering/agent.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/tools/suggestion_filtering/prompts.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/utils.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/bugbug/vectordb.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/pyproject.toml +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/__init__.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/analyze_training_metrics.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/backout_related_test_regressions.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/bug_classifier.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/bug_retriever.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/check.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/check_all_metrics.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/ci_failures_matching.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/comment_classifier.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/comment_level_labeler.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/comment_resolver_runner.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/compatibility_report_classifier.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/gcp_logs_retriever.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/generate_sheet.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/get_type_labels.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/get_untriaged.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/github_issue_classifier.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/github_issue_retriever.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/inline_comments_data_collection.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/integration_test.sh +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/maintenance_effectiveness_indicator.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/microannotate_generator.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/past_bugs_by_unit.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/perf_alerts_retriever.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/perf_commit_risk_scorer.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/perf_regression_predictor.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/perf_scheduling_simulator.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/redundant_failures.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/regressor_finder.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/retrieve_ci_failures.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/retrieve_training_metrics.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/retrieve_try_pushes.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/review_comments_retriever.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/revision_retriever.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/test_scheduling_history_retriever.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/trainer.py +0 -0
- {bugbug-0.0.659 → bugbug-0.0.661}/scripts/trainer_extract_args.py +0 -0
bugbug-0.0.661/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.661
|
|
@@ -22,6 +22,9 @@ DATABASES = {}
|
|
|
22
22
|
|
|
23
23
|
logger = logging.getLogger(__name__)
|
|
24
24
|
|
|
25
|
+
# The size of the blocks read from the end of a DB by read_last.
|
|
26
|
+
READ_LAST_BLOCK_SIZE = 1024 * 1024
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
class LastModifiedNotAvailable(Exception):
|
|
27
30
|
pass
|
|
@@ -239,6 +242,44 @@ def read(path):
|
|
|
239
242
|
yield from store.read()
|
|
240
243
|
|
|
241
244
|
|
|
245
|
+
def read_last_lines(path: str, count: int) -> list[bytes]:
|
|
246
|
+
"""Read the last `count` serialized elements of an uncompressed JSON DB, from the oldest.
|
|
247
|
+
|
|
248
|
+
Only the end of the file is read, so it is fast also with very large DBs. The elements aren't
|
|
249
|
+
deserialized, so that callers can skip some of them cheaply.
|
|
250
|
+
"""
|
|
251
|
+
assert path in DATABASES
|
|
252
|
+
assert str(path).endswith(".json"), "Only uncompressed JSON DBs are supported"
|
|
253
|
+
|
|
254
|
+
if not os.path.exists(path) or count <= 0:
|
|
255
|
+
return []
|
|
256
|
+
|
|
257
|
+
with open(path, "rb") as f:
|
|
258
|
+
pos = f.seek(0, os.SEEK_END)
|
|
259
|
+
blocks: list[bytes] = []
|
|
260
|
+
newlines = 0
|
|
261
|
+
# One more newline than elements is needed to be sure the oldest one is complete (unless
|
|
262
|
+
# the start of the file is reached).
|
|
263
|
+
while pos > 0 and newlines <= count:
|
|
264
|
+
read_size = min(READ_LAST_BLOCK_SIZE, pos)
|
|
265
|
+
pos -= read_size
|
|
266
|
+
f.seek(pos)
|
|
267
|
+
block = f.read(read_size)
|
|
268
|
+
blocks.append(block)
|
|
269
|
+
newlines += block.count(b"\n")
|
|
270
|
+
|
|
271
|
+
lines = b"".join(reversed(blocks)).splitlines()
|
|
272
|
+
if pos > 0:
|
|
273
|
+
# The first line can be partial.
|
|
274
|
+
lines = lines[1:]
|
|
275
|
+
return [line for line in lines[-count:] if line]
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def read_last(path: str, count: int) -> list:
|
|
279
|
+
"""Read the last `count` elements of an uncompressed JSON DB, from the oldest (see read_last_lines)."""
|
|
280
|
+
return [orjson.loads(line) for line in read_last_lines(path, count)]
|
|
281
|
+
|
|
282
|
+
|
|
242
283
|
def size(path):
|
|
243
284
|
assert path in DATABASES
|
|
244
285
|
|
|
@@ -17,6 +17,7 @@ import os
|
|
|
17
17
|
import pickle
|
|
18
18
|
import re
|
|
19
19
|
import shelve
|
|
20
|
+
import shutil
|
|
20
21
|
import subprocess
|
|
21
22
|
import sys
|
|
22
23
|
import threading
|
|
@@ -26,6 +27,7 @@ from typing import Collection, Iterable, Iterator, NamedTuple, NewType, Set, Uni
|
|
|
26
27
|
|
|
27
28
|
import hglib
|
|
28
29
|
import lmdb
|
|
30
|
+
import orjson
|
|
29
31
|
import requests
|
|
30
32
|
import rs_parsepatch
|
|
31
33
|
import tenacity
|
|
@@ -321,6 +323,183 @@ def get_commits(
|
|
|
321
323
|
)
|
|
322
324
|
|
|
323
325
|
|
|
326
|
+
# How many commits get_last_commit reads from the end of the commits DB before falling back to
|
|
327
|
+
# reading all of them.
|
|
328
|
+
LAST_COMMIT_RECENT_COMMITS = 256
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def get_last_commit(
|
|
332
|
+
include_no_bug: bool = False,
|
|
333
|
+
include_backouts: bool = False,
|
|
334
|
+
include_ignored: bool = False,
|
|
335
|
+
) -> CommitDict | None:
|
|
336
|
+
"""Return the last commit that get_commits would return, or None if it would return none.
|
|
337
|
+
|
|
338
|
+
Only the end of the commits DB is read, unless none of the last commits passes the filters.
|
|
339
|
+
"""
|
|
340
|
+
filters = {
|
|
341
|
+
"include_no_bug": include_no_bug,
|
|
342
|
+
"include_backouts": include_backouts,
|
|
343
|
+
"include_ignored": include_ignored,
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
recent_commits = db.read_last(COMMITS_DB, LAST_COMMIT_RECENT_COMMITS)
|
|
347
|
+
last_commit = collections.deque(filter_commits(recent_commits, **filters), maxlen=1)
|
|
348
|
+
# If fewer commits than requested were read, the whole DB was read.
|
|
349
|
+
if not last_commit and len(recent_commits) == LAST_COMMIT_RECENT_COMMITS:
|
|
350
|
+
logger.info("None of the last commits passes the filters, reading all commits")
|
|
351
|
+
last_commit = collections.deque(get_commits(**filters), maxlen=1)
|
|
352
|
+
|
|
353
|
+
return last_commit[0] if last_commit else None
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
# The offset of each commit in the commits DB, by node, and the nodes of the commits of each bug (by
|
|
357
|
+
# "bug:<id>" keys, see _get_bug_key), to find them without reading the whole DB.
|
|
358
|
+
COMMITS_INDEX_DB = "data/commits_index.lmdb"
|
|
359
|
+
# The size of the part of the commits DB which is indexed.
|
|
360
|
+
COMMITS_INDEX_SIZE_KEY = b"$indexed_size$"
|
|
361
|
+
# The serialized commits start with their node, followed by their author and bug ID (see
|
|
362
|
+
# Commit.to_dict). The key can't be found inside the author, as its quotes are escaped.
|
|
363
|
+
COMMIT_LINE_PREFIX = b'{"node":"'
|
|
364
|
+
COMMIT_BUG_ID_KEY = b',"bug_id":'
|
|
365
|
+
COMMITS_INDEX_BLOCK_SIZE = 16 * 1024 * 1024
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def _get_bug_key(bug_id: int) -> bytes:
|
|
369
|
+
return b"bug:%d" % bug_id
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
def _split_nodes(nodes: bytes) -> list[bytes]:
|
|
373
|
+
return [nodes[i : i + 40] for i in range(0, len(nodes), 40)]
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def _parse_commit_line(line: bytes) -> tuple[bytes, int | None]:
|
|
377
|
+
"""Get the node and the bug ID of a serialized commit, without parsing it whole if possible."""
|
|
378
|
+
if line.startswith(COMMIT_LINE_PREFIX):
|
|
379
|
+
bug_id_start = line.find(COMMIT_BUG_ID_KEY)
|
|
380
|
+
if bug_id_start != -1:
|
|
381
|
+
value_start = bug_id_start + len(COMMIT_BUG_ID_KEY)
|
|
382
|
+
value_end = line.find(b",", value_start)
|
|
383
|
+
value = line[value_start : value_end if value_end != -1 else -1]
|
|
384
|
+
node_start = len(COMMIT_LINE_PREFIX)
|
|
385
|
+
return (
|
|
386
|
+
line[node_start : node_start + 40],
|
|
387
|
+
None if value == b"null" else int(value),
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
commit = orjson.loads(line)
|
|
391
|
+
return commit["node"].encode("ascii"), commit.get("bug_id")
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def _update_commits_index(index: LMDBDict) -> None:
|
|
395
|
+
# The offset in the DB of the start of `pending`, the part of the DB read but not indexed yet.
|
|
396
|
+
pos = int(bytes(index.get(COMMITS_INDEX_SIZE_KEY, b"0")))
|
|
397
|
+
pending = b""
|
|
398
|
+
|
|
399
|
+
with open(COMMITS_DB, "rb") as f:
|
|
400
|
+
f.seek(pos)
|
|
401
|
+
# The DB is read in blocks, as mapping it in memory would make it count as used memory.
|
|
402
|
+
while block := f.read(COMMITS_INDEX_BLOCK_SIZE):
|
|
403
|
+
pending += block
|
|
404
|
+
start = 0
|
|
405
|
+
# Only the complete lines are indexed, in case the DB is being written to.
|
|
406
|
+
while (end := pending.find(b"\n", start)) != -1:
|
|
407
|
+
node, bug_id = _parse_commit_line(pending[start:end])
|
|
408
|
+
index[node] = str(pos + start).encode("ascii")
|
|
409
|
+
if bug_id is not None:
|
|
410
|
+
bug_key = _get_bug_key(bug_id)
|
|
411
|
+
index[bug_key] = bytes(index.get(bug_key, b"")) + node
|
|
412
|
+
start = end + 1
|
|
413
|
+
pending = pending[start:]
|
|
414
|
+
pos += start
|
|
415
|
+
|
|
416
|
+
index[COMMITS_INDEX_SIZE_KEY] = str(pos).encode("ascii")
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def delete_commits_index() -> None:
|
|
420
|
+
"""Delete the index of the commits DB, which is wrong once the DB is rewritten."""
|
|
421
|
+
shutil.rmtree(COMMITS_INDEX_DB, ignore_errors=True)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def update_commits_index() -> None:
|
|
425
|
+
"""Index the commits added to the commits DB since the last update."""
|
|
426
|
+
index = LMDBDict(COMMITS_INDEX_DB)
|
|
427
|
+
try:
|
|
428
|
+
_update_commits_index(index)
|
|
429
|
+
finally:
|
|
430
|
+
index.close()
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def _get_commits_offsets(nodes: Iterable[str]) -> dict[str, int]:
|
|
434
|
+
"""Return the offsets in the commits DB of the commits among `nodes` which are in it.
|
|
435
|
+
|
|
436
|
+
The index of the DB is updated first with the commits added to the DB since the last update.
|
|
437
|
+
"""
|
|
438
|
+
if not os.path.exists(COMMITS_DB):
|
|
439
|
+
return {}
|
|
440
|
+
|
|
441
|
+
index = LMDBDict(COMMITS_INDEX_DB)
|
|
442
|
+
try:
|
|
443
|
+
_update_commits_index(index)
|
|
444
|
+
return {
|
|
445
|
+
node: int(bytes(offset))
|
|
446
|
+
for node in nodes
|
|
447
|
+
if (offset := index.get(node.encode("ascii"))) is not None
|
|
448
|
+
}
|
|
449
|
+
finally:
|
|
450
|
+
index.close()
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def get_bug_nodes_in_db(bug_ids: Iterable[int]) -> dict[int, list[str]]:
|
|
454
|
+
"""Return the nodes of the commits of each of `bug_ids` which are in the commits DB.
|
|
455
|
+
|
|
456
|
+
The nodes are in the order of the DB. The index of the DB is updated first with the commits
|
|
457
|
+
added to the DB since the last update.
|
|
458
|
+
"""
|
|
459
|
+
if not os.path.exists(COMMITS_DB):
|
|
460
|
+
return {bug_id: [] for bug_id in bug_ids}
|
|
461
|
+
|
|
462
|
+
index = LMDBDict(COMMITS_INDEX_DB)
|
|
463
|
+
try:
|
|
464
|
+
_update_commits_index(index)
|
|
465
|
+
return {
|
|
466
|
+
bug_id: [
|
|
467
|
+
node.decode("ascii")
|
|
468
|
+
for node in _split_nodes(bytes(index.get(_get_bug_key(bug_id), b"")))
|
|
469
|
+
]
|
|
470
|
+
for bug_id in bug_ids
|
|
471
|
+
}
|
|
472
|
+
finally:
|
|
473
|
+
index.close()
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def get_nodes_in_db(nodes: Iterable[str]) -> set[str]:
|
|
477
|
+
"""Return the commits among `nodes` which are in the commits DB."""
|
|
478
|
+
return set(_get_commits_offsets(nodes))
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
def get_commits_from_db(nodes: Iterable[str]) -> dict[str, CommitDict]:
|
|
482
|
+
"""Return the commits among `nodes` which are already in the commits DB, by node.
|
|
483
|
+
|
|
484
|
+
These commits can't be mined again (with save=False), as their experience features would be
|
|
485
|
+
calculated after the ones of the commits pushed after them, which are in the experiences DB.
|
|
486
|
+
The commits are found through an index of the DB.
|
|
487
|
+
"""
|
|
488
|
+
offsets = _get_commits_offsets(nodes)
|
|
489
|
+
if not offsets:
|
|
490
|
+
return {}
|
|
491
|
+
|
|
492
|
+
commits: dict[str, CommitDict] = {}
|
|
493
|
+
with open(COMMITS_DB, "rb") as f:
|
|
494
|
+
for node, offset in offsets.items():
|
|
495
|
+
f.seek(offset)
|
|
496
|
+
commit = orjson.loads(f.readline())
|
|
497
|
+
assert commit["node"] == node, f"The commits index is wrong for {node}"
|
|
498
|
+
commits[node] = commit
|
|
499
|
+
|
|
500
|
+
return commits
|
|
501
|
+
|
|
502
|
+
|
|
324
503
|
def get_revision_id(commit: CommitDict) -> int | None:
|
|
325
504
|
match = PHABRICATOR_REVISION_REGEX.search(commit["desc"])
|
|
326
505
|
if not match:
|
|
@@ -1045,6 +1224,22 @@ def get_revs(hg, rev_start=0, rev_end="default"):
|
|
|
1045
1224
|
return x.splitlines()
|
|
1046
1225
|
|
|
1047
1226
|
|
|
1227
|
+
def get_new_revs(hg: hglib.client, base: str, head: str) -> list[bytes]:
|
|
1228
|
+
"""Get the non-merge commits on the default branch which are ancestors of `head`, but not of `base`.
|
|
1229
|
+
|
|
1230
|
+
Unlike the commits after `base` by revision number, these don't include the commits from other
|
|
1231
|
+
repositories pulled in the same clone (e.g. try).
|
|
1232
|
+
"""
|
|
1233
|
+
args = hglib.util.cmdbuilder(
|
|
1234
|
+
b"log",
|
|
1235
|
+
template="{node}\n",
|
|
1236
|
+
no_merges=True,
|
|
1237
|
+
branch="default",
|
|
1238
|
+
rev=f"::{head} - ::{base}",
|
|
1239
|
+
)
|
|
1240
|
+
return hg.rawcommand(args).splitlines()
|
|
1241
|
+
|
|
1242
|
+
|
|
1048
1243
|
class Experiences:
|
|
1049
1244
|
def __init__(self, save):
|
|
1050
1245
|
self.save = save
|
|
@@ -1296,22 +1491,30 @@ def set_commits_to_ignore(
|
|
|
1296
1491
|
|
|
1297
1492
|
|
|
1298
1493
|
def download_coverage_mapping() -> None:
|
|
1494
|
+
# The DB is built from the whole file, which is large, so only when it changes.
|
|
1495
|
+
is_built = os.path.exists("data/coverage_mapping.lmdb")
|
|
1299
1496
|
commit_to_coverage = get_coverage_mapping(False)
|
|
1300
1497
|
|
|
1301
1498
|
try:
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1499
|
+
if (
|
|
1500
|
+
utils.download_check_etag(
|
|
1501
|
+
"https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/project.relman.code-coverage.production.cron.latest/artifacts/public/commit_coverage.json.zst",
|
|
1502
|
+
"data/coverage_mapping.json.zst",
|
|
1503
|
+
)
|
|
1504
|
+
or not is_built
|
|
1505
|
+
):
|
|
1506
|
+
zstd_decompress("data/coverage_mapping.json")
|
|
1507
|
+
assert os.path.exists("data/coverage_mapping.json")
|
|
1309
1508
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1509
|
+
with open("data/coverage_mapping.json", "r") as f:
|
|
1510
|
+
data = json.load(f)
|
|
1312
1511
|
|
|
1313
|
-
|
|
1314
|
-
|
|
1512
|
+
for commit_hash, commit_stats in data.items():
|
|
1513
|
+
commit_to_coverage[commit_hash.encode("utf-8")] = pickle.dumps(
|
|
1514
|
+
commit_stats
|
|
1515
|
+
)
|
|
1516
|
+
else:
|
|
1517
|
+
logger.info("The commit->coverage mapping didn't change")
|
|
1315
1518
|
except requests.exceptions.HTTPError as e:
|
|
1316
1519
|
logger.error("Failure downloading commit->coverage mapping %s", e)
|
|
1317
1520
|
|
|
@@ -1358,18 +1561,26 @@ def set_commit_coverage(commits: Iterable[CommitDict]) -> None:
|
|
|
1358
1561
|
|
|
1359
1562
|
|
|
1360
1563
|
def download_component_mapping():
|
|
1564
|
+
# The DB is built from the whole file, which is large, so only when it changes.
|
|
1565
|
+
is_built = os.path.exists("data/component_mapping.lmdb")
|
|
1361
1566
|
path_to_component = get_component_mapping(False)
|
|
1362
1567
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1568
|
+
if (
|
|
1569
|
+
utils.download_check_etag(
|
|
1570
|
+
"https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/gecko.v2.mozilla-central.latest.source.source-bugzilla-info/artifacts/public/components.json",
|
|
1571
|
+
"data/component_mapping.json",
|
|
1572
|
+
)
|
|
1573
|
+
or not is_built
|
|
1574
|
+
):
|
|
1575
|
+
with open("data/component_mapping.json", "r") as f:
|
|
1576
|
+
data = json.load(f)
|
|
1370
1577
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1578
|
+
for path, component in data.items():
|
|
1579
|
+
path_to_component[path.encode("utf-8")] = "::".join(component).encode(
|
|
1580
|
+
"utf-8"
|
|
1581
|
+
)
|
|
1582
|
+
else:
|
|
1583
|
+
logger.info("The file->component mapping didn't change")
|
|
1373
1584
|
|
|
1374
1585
|
close_component_mapping()
|
|
1375
1586
|
|
|
@@ -1501,7 +1712,11 @@ def download_commits(
|
|
|
1501
1712
|
# Fixing https://github.com/mozilla/bugbug/issues/3131
|
|
1502
1713
|
mp_context=mp.get_context("fork"),
|
|
1503
1714
|
) as executor:
|
|
1504
|
-
|
|
1715
|
+
# Large chunks reduce the overhead when mining many commits, but with few of them
|
|
1716
|
+
# (e.g. when updating the DB) they would leave most processes idle: give several
|
|
1717
|
+
# chunks to each process.
|
|
1718
|
+
chunksize = max(1, min(64, commits_num // ((cpu_count or 1) * 4)))
|
|
1719
|
+
commits_iter = executor.map(_transform, commits, chunksize=chunksize)
|
|
1505
1720
|
commits_iter = tqdm(commits_iter, total=commits_num)
|
|
1506
1721
|
commits = tuple(commits_iter)
|
|
1507
1722
|
else:
|
|
@@ -1558,6 +1773,27 @@ def get_backsout(hg: hglib.client, revs: list[bytes]) -> dict[str, list[str]]:
|
|
|
1558
1773
|
}
|
|
1559
1774
|
|
|
1560
1775
|
|
|
1776
|
+
def get_backedoutby(hg: hglib.client, revs: list[bytes]) -> dict[str, str]:
|
|
1777
|
+
"""Get the node of the commit backing out each of the given commits ("" if none).
|
|
1778
|
+
|
|
1779
|
+
Only the backouts which are in the local repository are known.
|
|
1780
|
+
"""
|
|
1781
|
+
if len(revs) == 0:
|
|
1782
|
+
return {}
|
|
1783
|
+
|
|
1784
|
+
args = hglib.util.cmdbuilder(
|
|
1785
|
+
b"log",
|
|
1786
|
+
template="{node}\\0{backedoutby}\\0",
|
|
1787
|
+
rev=revs,
|
|
1788
|
+
)
|
|
1789
|
+
out = hg.rawcommand(args).split(b"\x00")[:-1]
|
|
1790
|
+
|
|
1791
|
+
return {
|
|
1792
|
+
node.decode("ascii"): backedoutby.decode("ascii")
|
|
1793
|
+
for node, backedoutby in hglib.util.grouper(2, out)
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
|
|
1561
1797
|
BACKOUT_DESC_RE = re.compile(
|
|
1562
1798
|
r"^(Backed out|Back out|Backout|Revert\b)|This reverts commit", re.I | re.M
|
|
1563
1799
|
)
|
|
@@ -1653,6 +1889,7 @@ def update_commits(repo_dir: str | None = None) -> None:
|
|
|
1653
1889
|
refresh_backouts_and_ignored(repo_dir, commits)
|
|
1654
1890
|
|
|
1655
1891
|
db.write(COMMITS_DB, commits)
|
|
1892
|
+
delete_commits_index()
|
|
1656
1893
|
|
|
1657
1894
|
|
|
1658
1895
|
def clean(hg, repo_dir):
|
|
@@ -1702,6 +1939,10 @@ def clone(
|
|
|
1702
1939
|
if "abort: repository" not in str(e) and "not found" not in str(e):
|
|
1703
1940
|
raise
|
|
1704
1941
|
|
|
1942
|
+
# robustcheckout pulls twice: into the pooled store, and then into the share. mozext records
|
|
1943
|
+
# the pushes in the `changetracker.db` of each repository (not in the shared store), so it would
|
|
1944
|
+
# download the whole pushlog for both pulls, and the copy of the pooled store is never used. Its
|
|
1945
|
+
# database is disabled for the clone, and the pushes are retrieved once by pulling in the share.
|
|
1705
1946
|
cmd = _build_hg_cmd(
|
|
1706
1947
|
"robustcheckout",
|
|
1707
1948
|
url,
|
|
@@ -1711,9 +1952,13 @@ def clone(
|
|
|
1711
1952
|
networkattempts=7,
|
|
1712
1953
|
branch=b"default",
|
|
1713
1954
|
noupdate=not update,
|
|
1955
|
+
config=b"mozext.disable_local_database=true",
|
|
1714
1956
|
)
|
|
1715
1957
|
subprocess.run(cmd, check=True)
|
|
1716
1958
|
|
|
1959
|
+
with hglib.open(repo_dir) as hg:
|
|
1960
|
+
hg.pull(update=update)
|
|
1961
|
+
|
|
1717
1962
|
logger.info("%s cloned", repo_dir)
|
|
1718
1963
|
|
|
1719
1964
|
|
|
@@ -1758,6 +2003,39 @@ def pull(repo_dir: str, branch: str, revision: str, update: bool = False) -> Non
|
|
|
1758
2003
|
trigger_pull()
|
|
1759
2004
|
|
|
1760
2005
|
|
|
2006
|
+
def get_stack(repo_dir: str, branch: str, rev: str) -> list[bytes]:
|
|
2007
|
+
"""The nodes of the patches in the stack of a revision, like utils.get_hgmo_stack.
|
|
2008
|
+
|
|
2009
|
+
On try, they are computed from the local repository with the automationrelevant
|
|
2010
|
+
revset of the hgmo extension, which hg.mozilla.org uses for automationrelevance:
|
|
2011
|
+
the draft ancestors of the revision (from the phases pulled from try). On other
|
|
2012
|
+
repositories, the stack is made of the changesets of the push of the revision,
|
|
2013
|
+
which are only known by hg.mozilla.org, so it is retrieved from there.
|
|
2014
|
+
"""
|
|
2015
|
+
if branch != "try" or not re.fullmatch(r"[0-9a-f]{40}", rev):
|
|
2016
|
+
return utils.get_hgmo_stack(branch, rev)
|
|
2017
|
+
|
|
2018
|
+
with hglib.open(repo_dir) as hg:
|
|
2019
|
+
changesets = json.loads(
|
|
2020
|
+
hg.rawcommand(
|
|
2021
|
+
hglib.util.cmdbuilder(
|
|
2022
|
+
b"log",
|
|
2023
|
+
rev=f"sort(automationrelevant({rev}))".encode("ascii"),
|
|
2024
|
+
template=b"json(node, files)",
|
|
2025
|
+
config=["hgmo.automationrelevantdraftancestors=true"],
|
|
2026
|
+
)
|
|
2027
|
+
)
|
|
2028
|
+
)
|
|
2029
|
+
|
|
2030
|
+
return [
|
|
2031
|
+
changeset["node"].encode("ascii")
|
|
2032
|
+
for changeset in changesets
|
|
2033
|
+
# Like get_hgmo_stack, don't analyze empty changesets or changesets which
|
|
2034
|
+
# simply specify try parameters.
|
|
2035
|
+
if changeset["files"] not in ([], ["try_task_config.json"])
|
|
2036
|
+
]
|
|
2037
|
+
|
|
2038
|
+
|
|
1761
2039
|
def get_commit_patches(repo_dir: str, revs: list[bytes]) -> Iterator[bytes]:
|
|
1762
2040
|
"""Export each revision as its own git-formatted patch (see get_commit_patch).
|
|
1763
2041
|
|
|
@@ -79,6 +79,12 @@ db.register(
|
|
|
79
79
|
TEST_GROUP_SCHEDULING_DB = "data/test_group_scheduling_history.pickle"
|
|
80
80
|
PAST_FAILURES_GROUP_DB = "past_failures_group.lmdb.tar.zst"
|
|
81
81
|
TOUCHED_TOGETHER_DB = "touched_together.lmdb.tar.zst"
|
|
82
|
+
# The number of commits at the end of the commits DB among which the last commit analyzed for the
|
|
83
|
+
# touched together DB is looked for, and how many of them before it are read too (see
|
|
84
|
+
# _get_commits_from). The window allows the DB to be updated quickly with up to about two weeks of
|
|
85
|
+
# commits.
|
|
86
|
+
TOUCHED_TOGETHER_RECENT_COMMITS = 10000
|
|
87
|
+
TOUCHED_TOGETHER_RECENT_MARGIN = 2000
|
|
82
88
|
db.register(
|
|
83
89
|
TEST_GROUP_SCHEDULING_DB,
|
|
84
90
|
"https://community-tc.services.mozilla.com/api/index/v1/task/project.bugbug.data_test_group_scheduling_history.latest/artifacts/public/test_group_scheduling_history.pickle.zst",
|
|
@@ -1079,6 +1085,45 @@ def get_cochange_pmi(source_dirs: Iterable[str], runnable_dirs: Iterable[str]) -
|
|
|
1079
1085
|
return best
|
|
1080
1086
|
|
|
1081
1087
|
|
|
1088
|
+
def _get_commits_from(
|
|
1089
|
+
last_analyzed: bytes | memoryview | None,
|
|
1090
|
+
) -> Iterable[repository.CommitDict]:
|
|
1091
|
+
"""The commits of the commits DB from where the touched together DB needs to be updated.
|
|
1092
|
+
|
|
1093
|
+
They are filtered like repository.get_commits does. When the last analyzed commit is among the last TOUCHED_TOGETHER_RECENT_COMMITS commits, the
|
|
1094
|
+
commits start TOUCHED_TOGETHER_RECENT_MARGIN commits before it, so that the revisions sent to
|
|
1095
|
+
update_touched_together which are slightly before it (as commits can be in a different order
|
|
1096
|
+
in mozilla-central and autoland) are found. Otherwise, all the commits are read, which is much
|
|
1097
|
+
slower as the commits DB is very large.
|
|
1098
|
+
"""
|
|
1099
|
+
if last_analyzed is not None:
|
|
1100
|
+
last_analyzed = bytes(last_analyzed)
|
|
1101
|
+
lines = db.read_last_lines(
|
|
1102
|
+
repository.COMMITS_DB, TOUCHED_TOGETHER_RECENT_COMMITS
|
|
1103
|
+
)
|
|
1104
|
+
# Only the commit with the node is deserialized (if the serialization changed, the commit
|
|
1105
|
+
# wouldn't be found, and all the commits would be read).
|
|
1106
|
+
needle = b'"node":"' + last_analyzed + b'"'
|
|
1107
|
+
position = next(
|
|
1108
|
+
(
|
|
1109
|
+
i
|
|
1110
|
+
for i, line in enumerate(lines)
|
|
1111
|
+
if needle in line
|
|
1112
|
+
and orjson.loads(line)["node"] == last_analyzed.decode()
|
|
1113
|
+
),
|
|
1114
|
+
None,
|
|
1115
|
+
)
|
|
1116
|
+
if position is not None and position >= TOUCHED_TOGETHER_RECENT_MARGIN:
|
|
1117
|
+
del lines[: position - TOUCHED_TOGETHER_RECENT_MARGIN]
|
|
1118
|
+
return repository.filter_commits(orjson.loads(line) for line in lines)
|
|
1119
|
+
|
|
1120
|
+
logger.info(
|
|
1121
|
+
"The last analyzed commit is not among the last commits, reading all commits"
|
|
1122
|
+
)
|
|
1123
|
+
|
|
1124
|
+
return repository.get_commits()
|
|
1125
|
+
|
|
1126
|
+
|
|
1082
1127
|
def update_touched_together(
|
|
1083
1128
|
runnable_dirs: Collection[str] = (),
|
|
1084
1129
|
) -> Generator[None, Revision | None, None]:
|
|
@@ -1098,7 +1143,8 @@ def update_touched_together(
|
|
|
1098
1143
|
|
|
1099
1144
|
end_revision = yield
|
|
1100
1145
|
|
|
1101
|
-
|
|
1146
|
+
commits = _get_commits_from(last_analyzed)
|
|
1147
|
+
for commit in commits:
|
|
1102
1148
|
seen.add(commit["node"])
|
|
1103
1149
|
|
|
1104
1150
|
if can_start:
|
|
@@ -226,26 +226,19 @@ class CodeReviewTool(GenerativeModelTool):
|
|
|
226
226
|
async def generate_review_comments(
|
|
227
227
|
self, patch: Patch, patch_summary: str
|
|
228
228
|
) -> tuple[AgentResponse, list[dict]]:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
review_context_branch = self._review_context_branch
|
|
233
|
-
if review_context_repo is None:
|
|
234
|
-
repo_ref = await patch.github_repo_ref()
|
|
235
|
-
if repo_ref:
|
|
236
|
-
review_context_repo, review_context_branch = repo_ref
|
|
237
|
-
if review_context_repo:
|
|
238
|
-
from bugbug.tools.code_review.review_context import (
|
|
239
|
-
load_external_context_for_review,
|
|
240
|
-
)
|
|
229
|
+
from bugbug.tools.code_review.review_context import (
|
|
230
|
+
resolve_external_context_for_review,
|
|
231
|
+
)
|
|
241
232
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
233
|
+
external_context, manifest = await resolve_external_context_for_review(
|
|
234
|
+
patch,
|
|
235
|
+
self._review_context_repo,
|
|
236
|
+
review_context_branch=(
|
|
237
|
+
self._review_context_branch if self._review_context_repo else None
|
|
238
|
+
),
|
|
239
|
+
extra_context_toml=self._extra_context_toml,
|
|
240
|
+
content_overrides=self._content_overrides,
|
|
241
|
+
)
|
|
249
242
|
|
|
250
243
|
messages = [
|
|
251
244
|
HumanMessage(
|