diffcone 0.6.0__tar.gz → 0.6.1__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.
- {diffcone-0.6.0 → diffcone-0.6.1}/PKG-INFO +1 -1
- {diffcone-0.6.0 → diffcone-0.6.1}/pyproject.toml +1 -1
- {diffcone-0.6.0 → diffcone-0.6.1}/pyproject.toml.orig +1 -1
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/cache.py +1 -1
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/evidence_plan.py +29 -8
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/execution.py +5 -3
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/planner.py +78 -9
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/snapshot.py +72 -37
- {diffcone-0.6.0 → diffcone-0.6.1}/LICENSE +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/README.md +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/__init__.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/check.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/child.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/ci_report.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/classify.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/cli.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/collect.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/cython.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/declarations.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/discovery/__init__.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/discovery/asv_static.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/discovery/common.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/discovery/pytest_static.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/discovery/session_state.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/evidence.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/__init__.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/aliases.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/core.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/definitions.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/dynamics.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/facts.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/lazy.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/literals.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/patches.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/process.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/references.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/resolver.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/scopes.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/scripts.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/state.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/symbols.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/syntax.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/uses.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/indexer/writes.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/manifest.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/model.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/report.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/selection.py +0 -0
- {diffcone-0.6.0 → diffcone-0.6.1}/src/diffcone/testing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffcone
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: Static-first, function-level change-impact engine for Python: which tests and benchmarks a change can affect, and why
|
|
5
5
|
Keywords: test selection,test impact analysis,change impact,pytest,asv,ci
|
|
6
6
|
Author: Bearing Research
|
|
@@ -145,7 +145,7 @@ from diffcone.model import (
|
|
|
145
145
|
# and modules (indexer.uses); 28: __subclasses__ reads; 27: type
|
|
146
146
|
# parameters, unnameable build scripts as other files; 26: escaped values;
|
|
147
147
|
# 25: external sites; 24: docstring decorators; 23: open classes
|
|
148
|
-
INDEX_FORMAT =
|
|
148
|
+
INDEX_FORMAT = 74
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
def _indexer_fingerprint() -> str:
|
|
@@ -322,7 +322,7 @@ from diffcone.planner import (
|
|
|
322
322
|
merge_targets,
|
|
323
323
|
plan_from_indexes,
|
|
324
324
|
)
|
|
325
|
-
from diffcone.snapshot import
|
|
325
|
+
from diffcone.snapshot import GITLINK_MODE, diff_snapshots, split_root
|
|
326
326
|
|
|
327
327
|
# Dynamic references that stand for a child process (diffcone.indexer.scripts).
|
|
328
328
|
CHILD_PROGRAMS = (RUNS_PROGRAM, RUNS_SCRIPT)
|
|
@@ -940,6 +940,14 @@ class _Observers:
|
|
|
940
940
|
# the index reads none of them, but the recorder saw what tests ran
|
|
941
941
|
# and opened there.
|
|
942
942
|
self.outside: dict[str, str] = {}
|
|
943
|
+
# Every submodule of either index (``_file`` asks only about changed
|
|
944
|
+
# paths), and the changed ones outside the roots (plan_with_evidence).
|
|
945
|
+
self.gitlinks: set[str] = {
|
|
946
|
+
path
|
|
947
|
+
for index in (c_index, other)
|
|
948
|
+
for path, mode in index.file_modes.items()
|
|
949
|
+
if mode == GITLINK_MODE
|
|
950
|
+
}
|
|
943
951
|
self.seed_changes: set[str] = set()
|
|
944
952
|
self.seed_nodes: dict[str, str] = {}
|
|
945
953
|
self.escalated_modules: set[str] = set()
|
|
@@ -3537,6 +3545,14 @@ class _Observers:
|
|
|
3537
3545
|
"read where no test's record sees it",
|
|
3538
3546
|
)
|
|
3539
3547
|
return
|
|
3548
|
+
if path in self.gitlinks:
|
|
3549
|
+
# Its new commit is all the diff shows: which of its files changed
|
|
3550
|
+
# (sources a build compiles in, data tests read) is not known.
|
|
3551
|
+
self._select_all(
|
|
3552
|
+
Rule.UNOBSERVED_FILE,
|
|
3553
|
+
f"{path} {what}: a submodule, whose changed files the diff does not show",
|
|
3554
|
+
)
|
|
3555
|
+
return
|
|
3540
3556
|
# The content: opened or stat'ed, or an entry of a directory scanned
|
|
3541
3557
|
# with ``os.scandir`` (the entries' metadata is read without an event).
|
|
3542
3558
|
observed = [(path, self.evidence.import_paths), (_scanned(path), self.evidence.import_dirs)]
|
|
@@ -3632,21 +3648,23 @@ class _Observers:
|
|
|
3632
3648
|
|
|
3633
3649
|
def _changed_outside_roots(
|
|
3634
3650
|
repo: Path, commit: str, other: SourceIndex, source_roots: list[str] | None
|
|
3635
|
-
) -> dict[str, str]:
|
|
3651
|
+
) -> tuple[dict[str, str], set[str]]:
|
|
3636
3652
|
"""Paths changed between the recorded commit and ``other`` that lie
|
|
3637
|
-
outside every source root (none when a root is the repository itself)
|
|
3653
|
+
outside every source root (none when a root is the repository itself),
|
|
3654
|
+
and the changed submodules anywhere."""
|
|
3655
|
+
revision = other.snapshot.commit
|
|
3656
|
+
changed, gitlinks = diff_snapshots(repo, commit, revision, other.snapshot.kind)
|
|
3638
3657
|
dirs = [split_root(r)[0] for r in (source_roots or ["."])]
|
|
3639
3658
|
if "" in dirs:
|
|
3640
|
-
return {}
|
|
3641
|
-
|
|
3642
|
-
changed = changed_paths(repo, commit, revision, other.snapshot.kind)
|
|
3643
|
-
return {
|
|
3659
|
+
return {}, gitlinks
|
|
3660
|
+
outside = {
|
|
3644
3661
|
path: what
|
|
3645
3662
|
for path, what in changed.items()
|
|
3646
3663
|
if not any(path.startswith(d + "/") for d in dirs)
|
|
3647
3664
|
and path not in OWN_FILES
|
|
3648
3665
|
and not path.startswith(OWN_DIRS)
|
|
3649
3666
|
}
|
|
3667
|
+
return outside, gitlinks
|
|
3650
3668
|
|
|
3651
3669
|
|
|
3652
3670
|
def plan_with_evidence(
|
|
@@ -3704,7 +3722,10 @@ def plan_with_evidence(
|
|
|
3704
3722
|
runner_only = _runner_only(evidence_index, other, pytest_targets)
|
|
3705
3723
|
obs = _Observers(evidence_index, other, evidence, test_code, declared, runner_only)
|
|
3706
3724
|
if repo:
|
|
3707
|
-
obs.outside = _changed_outside_roots(
|
|
3725
|
+
obs.outside, gitlinks = _changed_outside_roots(
|
|
3726
|
+
Path(repo), evidence.commit, other, source_roots
|
|
3727
|
+
)
|
|
3728
|
+
obs.gitlinks |= gitlinks
|
|
3708
3729
|
obs.run()
|
|
3709
3730
|
observed.append(obs)
|
|
3710
3731
|
fallbacks += obs.fallbacks
|
|
@@ -198,7 +198,9 @@ def _mismatch_matters(path: str, roots: list[str]) -> bool:
|
|
|
198
198
|
root, a ``conftest.py`` or ASV configuration anywhere, and anything
|
|
199
199
|
``build_input`` names (dependency declarations, lock files, compiled
|
|
200
200
|
sources, CI files). Bytecode and diffcone's own directory never
|
|
201
|
-
matter.
|
|
201
|
+
matter. A submodule checked out at another commit, or with edits, is
|
|
202
|
+
a mismatch wherever it is (worktree_mismatch): a moved gitlink selects
|
|
203
|
+
every target."""
|
|
202
204
|
if is_bytecode(path) or path.startswith(OWN_DIRS):
|
|
203
205
|
return False
|
|
204
206
|
if any(root in ("", ".") or path.startswith(root + "/") for root in roots):
|
|
@@ -454,7 +456,7 @@ def worktree_mismatch(repo: Path, plan: Plan, outputs: Sequence[str] = ()) -> st
|
|
|
454
456
|
path
|
|
455
457
|
for path in {*differing, *untracked, *ignored, *flagged, *submodules}
|
|
456
458
|
if path
|
|
457
|
-
and _mismatch_matters(path, roots)
|
|
459
|
+
and (path in submodules or _mismatch_matters(path, roots))
|
|
458
460
|
and not any(path.startswith(d + "/") for d in outputs)
|
|
459
461
|
)
|
|
460
462
|
if not in_scope:
|
|
@@ -1785,7 +1787,7 @@ def _commits_in_range(repo: Path, revision_range: str) -> list[tuple[str, str, s
|
|
|
1785
1787
|
|
|
1786
1788
|
|
|
1787
1789
|
def _touches_python(repo: Path, parent: str, commit: str) -> bool:
|
|
1788
|
-
out = _git(repo, ["diff", "--name-only", "-z", parent, commit])
|
|
1790
|
+
out = _git(repo, ["diff", "--name-only", "-z", "--ignore-submodules=none", parent, commit])
|
|
1789
1791
|
return any(name.endswith(b".py") for name in out.split(b"\0"))
|
|
1790
1792
|
|
|
1791
1793
|
|
|
@@ -175,8 +175,8 @@ from diffcone.snapshot import (
|
|
|
175
175
|
WORKTREE,
|
|
176
176
|
GitError,
|
|
177
177
|
Snapshot,
|
|
178
|
-
changed_paths,
|
|
179
178
|
commit_description,
|
|
179
|
+
diff_snapshots,
|
|
180
180
|
file_id,
|
|
181
181
|
read_snapshot,
|
|
182
182
|
resolve_commit,
|
|
@@ -290,8 +290,21 @@ COMPILED_SUFFIXES = (
|
|
|
290
290
|
".cc",
|
|
291
291
|
".cpp",
|
|
292
292
|
".cxx",
|
|
293
|
+
".c++",
|
|
293
294
|
".hh",
|
|
294
295
|
".hpp",
|
|
296
|
+
".hxx",
|
|
297
|
+
".h++",
|
|
298
|
+
# Headers and template bodies that sources include (``.tcc``: Thrift's
|
|
299
|
+
# generated templates; ``.inl``, ``.ipp``, ``.inc``: inline parts).
|
|
300
|
+
".tcc",
|
|
301
|
+
".inl",
|
|
302
|
+
".ipp",
|
|
303
|
+
".inc",
|
|
304
|
+
# Assembly, and the exports a Windows build reads (``.def``).
|
|
305
|
+
".s",
|
|
306
|
+
".asm",
|
|
307
|
+
".def",
|
|
295
308
|
".f",
|
|
296
309
|
".f77",
|
|
297
310
|
".for",
|
|
@@ -300,6 +313,7 @@ COMPILED_SUFFIXES = (
|
|
|
300
313
|
".pyf",
|
|
301
314
|
".rs",
|
|
302
315
|
".cu",
|
|
316
|
+
".cuh",
|
|
303
317
|
".i",
|
|
304
318
|
".swg",
|
|
305
319
|
".m",
|
|
@@ -307,6 +321,23 @@ COMPILED_SUFFIXES = (
|
|
|
307
321
|
".src",
|
|
308
322
|
".in",
|
|
309
323
|
".tpl",
|
|
324
|
+
# Schemas a build compiles into sources (Thrift, FlatBuffers, protobuf).
|
|
325
|
+
".thrift",
|
|
326
|
+
".fbs",
|
|
327
|
+
".proto",
|
|
328
|
+
# CMake modules and scripts, patches a build applies to the libraries it
|
|
329
|
+
# fetches, and Meson's wrap files (which version of a subproject).
|
|
330
|
+
".cmake",
|
|
331
|
+
".patch",
|
|
332
|
+
".wrap",
|
|
333
|
+
# Bazel's rule files, autoconf's macros, make fragments, and linker
|
|
334
|
+
# scripts and version scripts (what a shared library exports).
|
|
335
|
+
".bzl",
|
|
336
|
+
".bazel",
|
|
337
|
+
".m4",
|
|
338
|
+
".mk",
|
|
339
|
+
".lds",
|
|
340
|
+
".ver",
|
|
310
341
|
".so",
|
|
311
342
|
".pyd",
|
|
312
343
|
".dylib",
|
|
@@ -332,6 +363,23 @@ BUILD_FILES = frozenset(
|
|
|
332
363
|
"meson.options",
|
|
333
364
|
"meson_options.txt",
|
|
334
365
|
"CMakeLists.txt",
|
|
366
|
+
"CMakePresets.json",
|
|
367
|
+
"CMakeUserPresets.json",
|
|
368
|
+
# C and C++ package managers: which libraries, at which versions.
|
|
369
|
+
"vcpkg.json",
|
|
370
|
+
"vcpkg-configuration.json",
|
|
371
|
+
"conanfile.txt", # conanfile.py: BUILD_SCRIPTS
|
|
372
|
+
"Brewfile",
|
|
373
|
+
# A linker version script: which symbols a shared library exports.
|
|
374
|
+
"symbols.map",
|
|
375
|
+
# Bazel (``BUILD.bazel`` and ``MODULE.bazel`` by their suffix) and
|
|
376
|
+
# autotools.
|
|
377
|
+
"BUILD",
|
|
378
|
+
"WORKSPACE",
|
|
379
|
+
"configure",
|
|
380
|
+
"configure.ac",
|
|
381
|
+
"configure.in",
|
|
382
|
+
"Makefile.am",
|
|
335
383
|
"Makefile",
|
|
336
384
|
"GNUmakefile",
|
|
337
385
|
"Pipfile",
|
|
@@ -365,6 +413,22 @@ BUILD_FILES = frozenset(
|
|
|
365
413
|
)
|
|
366
414
|
# Directories whose files configure continuous integration.
|
|
367
415
|
CI_DIRS = (".github/workflows/", ".github/actions/", ".circleci/", "ci/", ".ci/")
|
|
416
|
+
# Directories of third-party code a build compiles in or fetches, at any
|
|
417
|
+
# depth: what is there (sources, pinned versions such as Apache Arrow's
|
|
418
|
+
# ``cpp/thirdparty/versions.txt``, patches) is part of the build.
|
|
419
|
+
THIRD_PARTY_DIRS = frozenset(
|
|
420
|
+
(
|
|
421
|
+
"thirdparty",
|
|
422
|
+
"third_party",
|
|
423
|
+
"3rdparty",
|
|
424
|
+
"vendor",
|
|
425
|
+
"vendored",
|
|
426
|
+
"subprojects",
|
|
427
|
+
"extern",
|
|
428
|
+
"external",
|
|
429
|
+
"deps",
|
|
430
|
+
)
|
|
431
|
+
)
|
|
368
432
|
# Dependency declarations, by a word in their name or in the name of a
|
|
369
433
|
# directory holding them, in any case: ``requirements-dev.txt``,
|
|
370
434
|
# ``dev-requirements.txt``, ``Requirements.txt``, ``requirements.pip``,
|
|
@@ -382,7 +446,8 @@ def build_input(path: str) -> bool:
|
|
|
382
446
|
"""Whether a file decides what is compiled, installed or collected, or
|
|
383
447
|
how the tests run: a compiled source; build, pytest or task-runner
|
|
384
448
|
configuration; a dependency declaration or lock file (``uv.lock``,
|
|
385
|
-
``pylock.toml``); a
|
|
449
|
+
``pylock.toml``, ``vcpkg.json``); a file under a third-party directory
|
|
450
|
+
(THIRD_PARTY_DIRS); a continuous-integration file; a ``.env`` file; a
|
|
386
451
|
``.pth`` file (once installed, the interpreter runs its import lines at
|
|
387
452
|
start); or a distribution's metadata (under ``*.dist-info``,
|
|
388
453
|
``*.egg-info``, ``*.egg`` or ``*.egg-link``, which ``importlib.metadata``
|
|
@@ -401,6 +466,7 @@ def build_input(path: str) -> bool:
|
|
|
401
466
|
or name.endswith((".lock", ".pth"))
|
|
402
467
|
or (name.startswith("pylock.") and name.endswith(".toml"))
|
|
403
468
|
or lowered.startswith(CI_DIRS)
|
|
469
|
+
or any(part in THIRD_PARTY_DIRS or part.startswith("vendored-") for part in parts[:-1])
|
|
404
470
|
or (
|
|
405
471
|
name.endswith(DEPENDENCY_SUFFIXES)
|
|
406
472
|
and any(DEPENDENCY_NAME.search(part) for part in parts)
|
|
@@ -458,10 +524,11 @@ def _runner_files_outside_roots(
|
|
|
458
524
|
and how the tests run: the runners' configuration at the repository root
|
|
459
525
|
(``pyproject.toml``'s pytest table, ``asv.conf.json`` or ``.jsonc``
|
|
460
526
|
anywhere),
|
|
461
|
-
conftests,
|
|
462
|
-
declarations and lock files, compiled sources)
|
|
463
|
-
|
|
464
|
-
|
|
527
|
+
conftests, anything ``build_input`` names (build scripts, dependency
|
|
528
|
+
declarations and lock files, compiled sources), and submodules (a moved
|
|
529
|
+
gitlink: what changed inside it, vendored sources or test data, is not
|
|
530
|
+
in the diff). Inside a root such a file is an unanalysed file; out of
|
|
531
|
+
every root nothing else would see it change."""
|
|
465
532
|
if "" in (split_root(r)[0] for r in roots):
|
|
466
533
|
return []
|
|
467
534
|
if base.snapshot.committed:
|
|
@@ -473,7 +540,7 @@ def _runner_files_outside_roots(
|
|
|
473
540
|
else: # the index and the working tree
|
|
474
541
|
fixed = INDEX
|
|
475
542
|
other = head.snapshot if head.snapshot.is_worktree else base.snapshot
|
|
476
|
-
changed =
|
|
543
|
+
changed, gitlinks = diff_snapshots(repo, fixed, other.commit, other.kind)
|
|
477
544
|
dirs = [split_root(r)[0] for r in roots]
|
|
478
545
|
return sorted(
|
|
479
546
|
path
|
|
@@ -481,6 +548,7 @@ def _runner_files_outside_roots(
|
|
|
481
548
|
if not any(path.startswith(d + "/") for d in dirs)
|
|
482
549
|
and (
|
|
483
550
|
path in CONFIG_FILES
|
|
551
|
+
or path in gitlinks
|
|
484
552
|
or build_input(path)
|
|
485
553
|
or PurePosixPath(path).name in ("conftest.py", *ASV_CONFIGS)
|
|
486
554
|
)
|
|
@@ -1811,8 +1879,9 @@ def plan_from_indexes(
|
|
|
1811
1879
|
Fallback(
|
|
1812
1880
|
Rule.UNANALYSED_FILE,
|
|
1813
1881
|
"all_targets",
|
|
1814
|
-
f"{len(outside)} build, dependency or runner configuration file(s)
|
|
1815
|
-
f"source roots changed ({shown}
|
|
1882
|
+
f"{len(outside)} build, dependency or runner configuration file(s) or "
|
|
1883
|
+
f"submodule(s) outside the source roots changed ({shown}"
|
|
1884
|
+
f"{f', and {more} more' if more > 0 else ''}); they "
|
|
1816
1885
|
"decide what is installed and how the tests run, so every supplied target is "
|
|
1817
1886
|
"selected",
|
|
1818
1887
|
)
|
|
@@ -174,50 +174,83 @@ def has_entry(repo: Path, revision: str, path: str) -> bool:
|
|
|
174
174
|
return path.encode("utf-8", "surrogateescape") in out.split(b"\0")
|
|
175
175
|
|
|
176
176
|
|
|
177
|
+
def _diff_args(commit: str, revision: str, kind: str) -> list[str]:
|
|
178
|
+
"""``git diff --raw`` between ``commit`` and a snapshot, as changed_paths
|
|
179
|
+
compares them. ``--ignore-submodules=none``: a ``.gitmodules`` entry's
|
|
180
|
+
``ignore = all`` (or ``diff.ignoreSubmodules``) would otherwise hide a
|
|
181
|
+
moved gitlink, even between two commits."""
|
|
182
|
+
base = ["diff", "--raw", "-z", "--no-renames", "--ignore-submodules=none"]
|
|
183
|
+
if commit == INDEX and kind == SnapshotKind.WORKTREE:
|
|
184
|
+
return base
|
|
185
|
+
if kind == SnapshotKind.WORKTREE:
|
|
186
|
+
return [*base, commit]
|
|
187
|
+
if kind == SnapshotKind.INDEX:
|
|
188
|
+
return [*base, "--cached", commit]
|
|
189
|
+
return [*base, commit, revision]
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def diff_snapshots(
|
|
193
|
+
repo: Path, commit: str, revision: str, kind: str
|
|
194
|
+
) -> tuple[dict[str, str], set[str]]:
|
|
195
|
+
"""changed_paths, and the changed paths that are a submodule on either
|
|
196
|
+
side: a gitlink whose commit moved, or one added, deleted, or put in
|
|
197
|
+
place of a file. What a submodule holds (vendored sources, test data) is
|
|
198
|
+
not in the superproject's diff, only its new commit, so a planner cannot
|
|
199
|
+
see which of its files changed. One ``git diff`` gives both."""
|
|
200
|
+
fields = _git(repo, _diff_args(commit, revision, kind)).split(b"\0")
|
|
201
|
+
out: dict[str, str] = {}
|
|
202
|
+
gitlinks: set[str] = set()
|
|
203
|
+
# ``--raw -z``: ":<old mode> <new mode> <old id> <new id> <status>" NUL
|
|
204
|
+
# "<path>" NUL, per path (no renames, so one path each).
|
|
205
|
+
for header, raw_path in zip(fields[0::2], fields[1::2], strict=False):
|
|
206
|
+
if not raw_path:
|
|
207
|
+
continue
|
|
208
|
+
meta = header.decode("ascii", "replace").lstrip(":").split()
|
|
209
|
+
path = raw_path.decode("utf-8", "surrogateescape")
|
|
210
|
+
out[path] = {"A": "added", "D": "deleted"}.get(meta[-1][:1] if meta else "", "edited")
|
|
211
|
+
if GITLINK_MODE in meta[:2]:
|
|
212
|
+
gitlinks.add(path)
|
|
213
|
+
if kind == SnapshotKind.WORKTREE:
|
|
214
|
+
_add_worktree_changes(repo, commit, out)
|
|
215
|
+
return out, gitlinks
|
|
216
|
+
|
|
217
|
+
|
|
177
218
|
def changed_paths(repo: Path, commit: str, revision: str, kind: str) -> dict[str, str]:
|
|
178
219
|
"""Every path whose content differs between ``commit`` and a snapshot
|
|
179
220
|
(``kind``: a commit, the index or the working tree, untracked files
|
|
180
221
|
included), as path -> "added", "deleted" or "edited". ``commit`` may be
|
|
181
222
|
``INDEX`` when the snapshot is the working tree: the staged content is
|
|
182
223
|
then what it is compared with."""
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if path:
|
|
195
|
-
out[path] = {"A": "added", "D": "deleted"}.get(status[:1], "edited")
|
|
196
|
-
if kind == SnapshotKind.WORKTREE:
|
|
197
|
-
untracked = _git(repo, ["ls-files", "-z", "--others", "--exclude-standard"])
|
|
198
|
-
for raw in untracked.split(b"\0"):
|
|
199
|
-
path = raw.decode("utf-8", "surrogateescape")
|
|
200
|
-
if path and not is_bytecode(path):
|
|
201
|
-
out.setdefault(path, "added")
|
|
202
|
-
# The ignored Python files the working tree snapshot reads.
|
|
203
|
-
for path in ignored_python_files(repo, []):
|
|
224
|
+
return diff_snapshots(repo, commit, revision, kind)[0]
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def _add_worktree_changes(repo: Path, commit: str, out: dict[str, str]) -> None:
|
|
228
|
+
"""What ``git diff`` against the working tree leaves out: untracked
|
|
229
|
+
files, the ignored Python files the snapshot reads, and files flagged
|
|
230
|
+
assume-unchanged or skip-worktree."""
|
|
231
|
+
untracked = _git(repo, ["ls-files", "-z", "--others", "--exclude-standard"])
|
|
232
|
+
for raw in untracked.split(b"\0"):
|
|
233
|
+
path = raw.decode("utf-8", "surrogateescape")
|
|
234
|
+
if path and not is_bytecode(path):
|
|
204
235
|
out.setdefault(path, "added")
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
236
|
+
# The ignored Python files the working tree snapshot reads.
|
|
237
|
+
for path in ignored_python_files(repo, []):
|
|
238
|
+
out.setdefault(path, "added")
|
|
239
|
+
# ``git diff`` does not look at a file flagged assume-unchanged or
|
|
240
|
+
# skip-worktree: compare what is on disk with the commit.
|
|
241
|
+
for path, skip_worktree in sorted(_flagged_paths(repo, []).items()):
|
|
242
|
+
full = repo / path
|
|
243
|
+
present = full.is_file() or full.is_symlink()
|
|
244
|
+
if path in out or (skip_worktree and not present):
|
|
245
|
+
continue # a skip-worktree entry is not checked out by design
|
|
246
|
+
then = file_id(repo, commit, path)
|
|
247
|
+
if not present:
|
|
248
|
+
if then is not None: # assume-unchanged, deleted on disk
|
|
249
|
+
out[path] = "deleted"
|
|
250
|
+
elif then is None:
|
|
251
|
+
out[path] = "added"
|
|
252
|
+
elif file_id(repo, WORKTREE, path) != then:
|
|
253
|
+
out[path] = "edited"
|
|
221
254
|
|
|
222
255
|
|
|
223
256
|
def resolve_commit(repo: Path, revision: str) -> str:
|
|
@@ -351,6 +384,8 @@ BUILD_SCRIPTS = frozenset(
|
|
|
351
384
|
"toxfile.py",
|
|
352
385
|
"sitecustomize.py",
|
|
353
386
|
"usercustomize.py",
|
|
387
|
+
# Conan's recipe: which C and C++ libraries, at which versions.
|
|
388
|
+
"conanfile.py",
|
|
354
389
|
}
|
|
355
390
|
)
|
|
356
391
|
# ``build.py`` is also an ordinary module name. It is a build script
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|