Skip to content
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

Update Chorus to use Mercurial 6.5.1 and Python 3 #329

Merged
merged 13 commits into from
Dec 14, 2023
Merged

Conversation

rmunn
Copy link
Contributor

@rmunn rmunn commented Dec 6, 2023

sillsdev/Mercurial4Chorus#11 will need to be merged first, then this PR will be able to build.

This updates the included version of Mercurial to 6.5.1, using Python 3 instead of Python 2 (which hasn't received any security fixes in nearly four years, since it went end-of-life on January 1st, 2020).


This change is Reviewable

With the changes in Mercurial 6.5.1 and Python3, ChorusMerge now gets
correctly-encoded Unicode filenames as input, without needing to go
through a step where UTF-8 is double-encoded as CP1252.

We also modify one unit test that relied on the old, broken behavior.
A behavior change between Mercurial 3.3 and 6.5.1 means that these four
tests now fail due to Mercurial complaining that the username isn't set.
Since the absence of a username has nothing to do with the matter under
test, we should just change how these four tests are set up to include a
username so that Mercurial is satisfied.
Copy link

github-actions bot commented Dec 6, 2023

Test Results

       2 files  ±0     202 suites  ±0   1h 22m 44s ⏱️ + 38m 26s
   876 tests ±0     854 ✔️ ±0  22 💤 ±0  0 ±0 
1 998 runs  ±0  1 932 ✔️ ±0  66 💤 ±0  0 ±0 

Results for commit 13626ad. ± Comparison against base commit 74871cb.

♻️ This comment has been updated with latest results.

@hahn-kev
Copy link
Contributor

hahn-kev commented Dec 7, 2023

Ran a simple performance test on my machine using the new mercurial version for a large ~700mb project.

Version Speed
v3.3 2 min 40 sec
v6.5.1 2 min 0 sec

this gave about a 25% speed increase. In practice we might even see better if the speed boost comes from different network usage.

@rmunn rmunn linked an issue Dec 7, 2023 that may be closed by this pull request
@rmunn rmunn mentioned this pull request Dec 7, 2023
Copy link
Member

@ermshiperete ermshiperete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question, otherwise LGTM

src/ChorusMerge/Program.cs Show resolved Hide resolved
src/ChorusMerge.Tests/ChorusMergeTests.cs Show resolved Hide resolved
Copy link
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 6 files at r1, all commit messages.
Reviewable status: 1 of 6 files reviewed, 2 unresolved discussions (waiting on @ermshiperete and @rmunn)


src/LibChorus/VcsDrivers/Mercurial/HgRepository.cs line 255 at r1 (raw file):

			uiSection.Set("merge", mergetoolname);
			uiSection.Set("interactive", "True");

So this is needed in the latest mercurial to get the correct behavior?

@rmunn
Copy link
Contributor Author

rmunn commented Dec 7, 2023

src/LibChorus/VcsDrivers/Mercurial/HgRepository.cs line 255 at r1 (raw file):

Previously, jasonleenaylor (Jason Naylor) wrote…

So this is needed in the latest mercurial to get the correct behavior?

Yes. When Mercurial sees a conflict where one side changed a file while the other one deleted it, it prompts the user for what to do, taking input on stdin if stdin looks like a real tty, i.e. not connected to a pipe. If stdin is piped, Mercurial assumes it's not safe to take input from it, and so it will use the defaults for any prompt and not read stdin at all. The defaults for changed/deleted conflicts used to be "(c)hanged", but in Mercurial 3.7 those defaults were changed to "leave (u)nresolved", which breaks two rather important unit tests. (Specifically, FileDeletedLocallyAndChangedRemotelyKeepsChanged and FileDeletedRemotelyAndChangedLocallyKeepsChanged from HgWrappingTests).

However, if you have ui.interactive set to true, you can override Mercurial's "is stdin a tty?" check and force it to take input from stdin even if it's a pipe. At which point the code you wrote in 0893b36 to handle that conflict actually gets a chance to run, and correctly informs Mercurial that we do, in fact, want to keep the changed file. So by setting "ui.interactive = True" we get the status quo ante.

@rmunn
Copy link
Contributor Author

rmunn commented Dec 8, 2023

Looks like I'll need to update the file paths in the .wixproj file, as Mercurial 6.5.1 places files in different locations than Mercurial 3.3 did (for example, library.zip is now under lib/ instead of being in the root folder).

@rmunn
Copy link
Contributor Author

rmunn commented Dec 8, 2023

I'm going to need some help with updating the GeneratedMercurial.wxs file (made with WiX, apparently), because I'm completely unfamiliar with the WiX toolset and don't know where to start. @jasonleenaylor - any pointers on how I can get started updating the installer definition files? For example, what tool was used to generate them? I can't find the tool name in the Git logs, just a commit that checks in the generated files.

This automatically creates the GeneratedMercurial.wxs and
GeneratedMercurialExtensions.wxs files used in later build steps.
This is needed for the ChorusHub installer to build.
@rmunn
Copy link
Contributor Author

rmunn commented Dec 13, 2023

Figured out the generated .wxs files. Now they're just missing the .pyc files for the fixutf8 extension, because they didn't get included in the SL.Chorus.Mercurial package. I'll submit a new PR over at Mercurial4Chorus (or maybe just tweak sillsdev/Mercurial4Chorus#12 to include the necessary .pyc files) so that the .pyc files will be present. (We do want to distribute them, so that the Python interpreter doesn't have to create them on first run after users install this).

Copy link
Member

@ermshiperete ermshiperete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(oops, forgot to finish my comments...)

src/ChorusMerge/Program.cs Show resolved Hide resolved
@rmunn
Copy link
Contributor Author

rmunn commented Dec 14, 2023

Submitted the new PR I mentioned: sillsdev/Mercurial4Chorus#13

Once that's merged, I'll push a new commit to this PR that will update the installer with the correct .pyc file locations (they moved and got new names between Python 2 and Python 3), and then this PR should finally be able to build.

The location where Python stores .pyc files changed between Python 2
and Python 3, so we need to point the installer at the new location.
Apparently the NuGet package being pulled in by the 6.5.1-* qualifier is
too old and isn't including the recent fixes.
Now that we know that version 6.5.1.22 is building correctly, we can set
up to use that version or any later one.
@rmunn
Copy link
Contributor Author

rmunn commented Dec 14, 2023

Finally a green build with commit 2a3d101 — it seems I had the syntax wrong for the NuGet package dependency so I was pulling in an older version of SIL.Chorus.Mercurial that didn't have my bugfixes. I'm going to push one more commit going back to a wildcard package version, so that it's easier to pull in any subsequent bugfixes to the SIL.Chorus.Mercurial package, and then this PR will finally be ready for final review and merge.

The ChorusMerge code no longer matches the comment; update the comment
so we don't wonder in the future why the encoding games have gone away.
Copy link
Contributor Author

@rmunn rmunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've dismissed old discussions in Reviewable so that they don't hold up the merge. Once the build completes, this will finally be ready for approval and merging.

Dismissed @ermshiperete from 2 discussions.
Reviewable status: 1 of 9 files reviewed, all discussions resolved (waiting on @ermshiperete and @jasonleenaylor)

@rmunn
Copy link
Contributor Author

rmunn commented Dec 14, 2023

@ermshiperete - While we wait for the build to complete (should be done about an hour from the time of this comment), would you like to look at this again?

@jasonleenaylor - Any other concerns, or do you feel this is ready now?

CHANGELOG.md Outdated Show resolved Hide resolved
Fix typo

Co-authored-by: Eberhard Beilharz <[email protected]>
Copy link
Contributor Author

@rmunn rmunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dismissed @ermshiperete from a discussion.
Reviewable status: 1 of 10 files reviewed, all discussions resolved (waiting on @jasonleenaylor)

Copy link
Contributor Author

@rmunn rmunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 6 files at r1, 2 of 2 files at r2, 1 of 2 files at r3, 1 of 1 files at r4, 1 of 1 files at r5, 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @jasonleenaylor)

@rmunn rmunn enabled auto-merge (squash) December 14, 2023 15:32
@rmunn rmunn merged commit 3de3771 into master Dec 14, 2023
4 checks passed
@rmunn rmunn deleted the chore/hg-6.5.1 branch December 14, 2023 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update included Mercurial
4 participants