-
-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding DigestTrie/Snapshot diffing #14872
Conversation
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Use pants.engine.fs.SnapshotDiff for semantic names | ||
def diff( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just prefix this with an underscore to really ward off callers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that might make sense. In practice, users will probably consume this via a @rule
that computes a diff string in some format using difflib...? And so this would be an implementation detail of that @rule
rather than something consumed directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan is for this to be called in FmtResult.message
to compute the message. Well not "this" but pants.engine.fs.SnapshotDiff.from_snapshots
.
The test that fails seems unrelated to my changes (the new tests pass in the output)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks great!
# Use pants.engine.fs.SnapshotDiff for semantic names | ||
def diff( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that might make sense. In practice, users will probably consume this via a @rule
that computes a diff string in some format using difflib...? And so this would be an implementation detail of that @rule
rather than something consumed directly.
Related to the addition of |
Ahh! I think the rule parsing code should be flexible enough to handle this, but we can workaround it here. |
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
In order to handle the upcoming change to "unify" both
fmt
andlint
processes for formatters, we need to have the ability to find what files changed in a formatter rule run. This PR adds a recursivediff
function to the RustDigestTrie
, which is also exposed via thePySnapshot
/Snapshot
Python byding/type.The
diff
method returns a complete set of differences (ours/theirs files/dirs + changed) as this was readily available and could be useful in other contexts. For the purpose of my future changes, I just need the changed files.Tests have been added Python-side as that is easiest to author/grok.
[ci skip-build-wheels]