Update patch command#944
Merged
Merged
Conversation
Contributor
WalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as "CLI (update-patch)"
participant SP as "SuperProject"
participant Sub as "SubProject"
participant VCS as "Git/SVN LocalRepo"
participant Patch as "vcs.patch.reverse_patch"
User->>CLI: run update-patch <project(s)>
CLI->>SP: in_vcs()
SP-->>CLI: True/False
CLI->>SP: has_local_changes_in_dir(proj_path)
SP->>VCS: any_changes_or_untracked(path)
VCS-->>SP: bool
alt proceed
CLI->>Sub: update(patch_count = last_patch_index)
CLI->>Sub: diff(old_rev, current_rev, reverse=true)
Sub->>VCS: create_diff(old, new, ignore, reverse=true)
VCS-->>Patch: raw diff bytes
Patch->>Patch: reverse_patch(bytes)
Patch-->>CLI: reversed diff text
alt diff produced
CLI->>Sub: backup & overwrite last patch file
CLI->>Sub: update(patch_count=-1)
CLI-->>User: "Patch updated"
else no diff
CLI-->>User: "No diffs found"
end
else skip
CLI-->>User: "Skipped: local changes / no patch / not fetched"
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0a9e46e to
513130b
Compare
513130b to
e966aa8
Compare
Contributor
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@tests/test_patch.py`:
- Around line 298-315: The test currently passes in-memory strings to
apply_patch but apply_patch expects a patch file path and works against files
under a root directory; update the test to write patch_forward to a temporary
patch file and write the modified content to a real temp file (use the tmp_path
fixture), then call apply_patch with the patch file path (and root=tmp_path if
required) to produce restored and assert restored file contents equal original;
reference the existing symbols patch_forward, reverse_patch, apply_patch,
modified, original, and restored when locating where to change the test.
- Around line 6-12: The property test currently calls random.choice() and
random.shuffle() inside a `@given` test which prevents Hypothesis from controlling
randomness; replace direct random module calls by drawing a Hypothesis-managed
RNG via st.randoms() and use that RNG (the Random instance returned) for .choice
and .shuffle calls. Locate the failing test (the `@given-decorated` function that
uses random.choice and random.shuffle) and add a parameter drawn from
st.randoms(), then replace random.choice(...) and random.shuffle(...) with
rng.choice(...) and rng.shuffle(...), keeping the existing st imports
(st.randoms) so Hypothesis can reproduce and shrink failures.
Contributor
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@dfetch/commands/update_patch.py`:
- Around line 126-132: The reverse patch is being generated with old_revision=""
which diffs against the working tree and can become empty; change the call to
subproject.diff in update_patch.py so that when reverse=True you pass the
superproject's current revision (use superproject.current_revision()) as
old_revision instead of an empty string (and keep new_revision as before),
ensuring the reverse diff is computed against the superproject commit context.
In `@dfetch/vcs/svn.py`:
- Around line 206-211: In get_last_changed_revision, the directory check uses
the original target instead of the stripped string; change the os.path.isdir
call to use the computed target_str (or resolve/str() the Path into target_str)
so the isdir check and subsequent svnversion invocation operate on the same,
whitespace-trimmed path (update the os.path.isdir(target) reference in
get_last_changed_revision to os.path.isdir(target_str)).
This was referenced Feb 6, 2026
Merged
Merged
Merged
This was referenced Feb 20, 2026
Merged
This was referenced Mar 18, 2026
Merged
This was referenced Jun 12, 2026
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.
Fixes #614
Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.