-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Improve hg revset used by jest-changed-files #7880
Conversation
The old revset is `ancestor(.^, min(branch(.) and not min(branch(default)), max(public()))`. It can select public commits unintentionally in some cases. In the following two examples, commit A would be selected by the old code path as the "from revision". The new revset would select commit C instead, which is better because the developer won't want to test commits in the `B::C` range. Example 1 - Multiple named branches: E default (named branch), public : | D stable (named branch), draft (only commit the developer cases about) | | | C stable (named branch), public | : | | | B stable (named branch), public |/ A Example 2 - Multiple heads in the "default" named branch: E default (named branch), public, has a bigger revision number than C. : | D default (named branch), draft (only commit the developer cases about) | | | C default (named branch), public | : | | | B default (named branch), public |/ A Explanation of the `min(!public() & ::.)^` revset: With modern Mercurial, `!public()` is the way to select local commits that do not exist on other developer's repos. `& ::.` limits commits to only the current "feature branch" (branch in terms of the commit DAG, not hg named branches). `min` selects the first commit in the non-public feature branch, and `^` selects its immediate parent. Note: it's `!public() & ::.` instead of `::. & !public()` intentionally, because the former has a fast path [1]. [1]: See https://www.mercurial-scm.org/repo/hg/rev/c6c8a52e28c9077580dd2f0552eb2bd6d5e0d13c
Codecov Report
@@ Coverage Diff @@
## master #7880 +/- ##
=======================================
Coverage 58.46% 58.46%
=======================================
Files 178 178
Lines 6638 6638
Branches 5 6 +1
=======================================
Hits 3881 3881
Misses 2755 2755
Partials 2 2 Continue to review full report at Codecov.
|
The windows test failure seems unrelated to this change. |
I've never used mercurial, so not really able to contribute any meaningful review. The PR (#5476) seems to have changed it as an aside. Maybe @mjesun can comment on this? We have an e2e test for the basic functionality already: https://github.com/facebook/jest/blob/9ba62ada66f731880229073eb193e8cb60863ae3/e2e/__tests__/jestChangedFiles.test.js#L320-L322, so it seems not to be broken with your changes at least Windows failure not related (that test is a bit flaky 😞) |
I wasn't aware of the |
@quark-zju I just found an issue when executing |
@mjesun Sorry, I didn't think about that. I think |
@quark-zju I'm getting test failures after this PR.
Which version of mercurial should I use? $ hg --version
Mercurial Distributed SCM (version 4.9)
(see https://mercurial-scm.org for more information)
Copyright (C) 2005-2019 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
Same error as @SimenB on Linux, same Mercurial version. But I'm also getting a second one.
|
Edit: I think you commented on the PR not noticing @quark-zju's reply with changing the HG pattern. I'm making a PR with the updated pattern as we speak, since I verified it works. |
I just ran the integration test, not passing anything anywhere :D |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Changed the default
hg status --rev
parameter used by jest-changed-files so it's more correct in corner cases, and avoids the (incorrect) usage ofbranch()
which will be removed internally at Facebook.Test plan
I'm not sure how to test this exactly. But there are no new test breakage introduced by this change. Commit 64485f7 introduced the code but it didn't come with a test. Aside from that, I've made sure the revset works as advertised.
The old revset is
ancestor(.^, min(branch(.) and not min(branch(default)), max(public()))
.It can select public commits unintentionally in some cases.
In the following two examples, commit A would be selected by the old code path
as the "from revision". The new revset would select commit C instead, which
is better because the developer won't want to test commits in the
B::C
range.Example 1 - Multiple named branches:
Example 2 - Multiple heads in the "default" named branch:
Explanation of the
min(!public() & ::.)^
revset:With modern Mercurial,
!public()
is the way to select local commits thatdo not exist on other developer's repos.
& ::.
limits commits to only thecurrent "feature branch" (branch in terms of the commit DAG, not hg named
branches).
min
selects the first commit in the non-public feature branch,and
^
selects its immediate parent. Note: it's!public() & ::.
insteadof
::. & !public()
intentionally, because the former has a fast path.