feat: add SVN (Subversion) working copy support#255
Open
xiaoye5200 wants to merge 1 commit intotirth8205:mainfrom
Open
feat: add SVN (Subversion) working copy support#255xiaoye5200 wants to merge 1 commit intotirth8205:mainfrom
xiaoye5200 wants to merge 1 commit intotirth8205:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds first-class SVN support alongside the existing Git integration,
so that projects using Subversion can build and incrementally update
the knowledge graph without any manual configuration.
What changed
incremental.pyfind_svn_root()— walks up the directory tree to locate the SVNworking-copy root (handles both SVN 1.6 per-directory
.svnandthe single-root layout introduced in SVN 1.7).
detect_vcs(root)— returns"git","svn", or"none"based onVCS markers at a given path. Used internally to dispatch to the
correct VCS backend.
find_repo_root()— now falls back tofind_svn_root()when no.gitdirectory is found.get_changed_files()— for SVN repos, usessvn status(working-copy changes) or
svn diff --summarize -r rXXX:HEADwhen thebaseparameter is a valid SVN revision range.
get_staged_and_unstaged()— delegates tosvn statusfor SVN repos.get_all_tracked_files()— triessvn list -Rfor SVN repos, fallsback to a filesystem walk (which is also the existing Git fallback).
_svn_revision_info()— reads branch path and revision number fromsvn info._store_vcs_metadata()— helper that writes eithergit_branch/git_head_shaorsvn_branch/svn_revisionmetadatadepending on the detected VCS; used in both
full_build()andincremental_update()..svn/**toDEFAULT_IGNORE_PATTERNS.changes.pyparse_svn_diff_ranges()— runssvn diffand feeds the unified-diffoutput into the existing
_parse_unified_diff()for line-level changemapping. Accepts an optional revision range.
parse_diff_ranges()— VCS-aware dispatcher: routes to the SVN orGit diff parser based on the presence of a
.svnmarker.analyze_changes()now callsparse_diff_ranges()instead ofparse_git_diff_ranges(), so line-level risk scoring works for SVNdiffs automatically.
tools/review.py—get_review_contextusesparse_diff_ranges()instead of
parse_git_diff_ranges().tools/__init__.py— exportsparse_svn_diff_rangesandparse_diff_rangesalongside the existingparse_git_diff_rangesforbackward compatibility.
cli.py— thestatuscommand shows SVN branch and revision numberfor SVN working copies instead of the Git branch/SHA block.
Backward compatibility
All existing Git behavior is unchanged. The SVN path is only activated
when a
.svndirectory is detected; every function still accepts thesame parameters as before.
Testing
test_incremental.pyandtest_changes.pytests passwithout modification.
files in teardown) are unrelated to this PR.
Notes
svn list -Rqueries the server and may be slow on large repos;the filesystem-walk fallback kicks in automatically if it fails or
times out.
baseparameter semantics for SVN: a string matchingr?\d+(:r?\d+|:HEAD|:BASE|:COMMITTED)?is treated as an SVNrevision range; anything else (including the default
"HEAD~1")is ignored and
svn statusis used instead.