sillsdev / Mercurial4Chorus

Mercurial version used by Chorus
GNU General Public License v2.0
1 stars 3 forks source link

Update to Mercurial 6.5.1 #10

Closed rmunn closed 11 months ago

rmunn commented 1 year ago

I'll be updating the included Mercurial to 6.5.1, so that we can get rid of Python 2 and deploy Python 3 alongside Chorus. Some of my findings are:

diff -ur mercurial-6.5.1/mercurial/filemerge.py Mercurial/mercurial/filemerge.py
--- mercurial-6.5.1/mercurial/filemerge.py  2023-08-07 16:05:26.000000000 +0700
+++ Mercurial/mercurial/filemerge.py    2023-11-29 12:35:02.753765548 +0700
@@ -322,10 +322,10 @@
     prompts[b'fd'] = uipathfn(fd)
     try:
         if other.fctx.isabsent():
-            index = ui.promptchoice(_localchangedotherdeletedmsg % prompts, 2)
+            index = ui.promptchoice(_localchangedotherdeletedmsg % prompts, 0)
             choice = [b'local', b'other', b'unresolved'][index]
         elif local.fctx.isabsent():
-            index = ui.promptchoice(_otherchangedlocaldeletedmsg % prompts, 2)
+            index = ui.promptchoice(_otherchangedlocaldeletedmsg % prompts, 0)
             choice = [b'other', b'local', b'unresolved'][index]
         else:
             # IMPORTANT: keep the last line of this prompt ("What do you want to
rmunn commented 11 months ago

Further findings: we do still need to use fixutf8.py on Windows. The tests were passing earlier because the default test project name ("test projéct") was something that could be encoded in cp-1252 (the Windows "equivalent" of latin-1 with extra characters). Changing the test project name to something with non-Latin characters resulted in a bunch of test failures, mostly caused by some internal Mercurial functions not quite expecting the results that they got back from certain Python 3 library calls. (For example, if you do os.path.realpath(''), you get the current working directory. But for some reason, if and only if the current working directory contains non-Latin characters, you get the current working directory with \. appended. This causes the Mercurial code that says "is this file in the current repo?" to fail, because it relies on a string comparison between the filename and the current working directory.)

But I've gotten a version of fixutf8.py running correctly under Python 3 and Mercurial 6.5.1. I'll submit a PR to update both Mercurial and MercurialExtensions accordingly; once that PR is merged into Mercurial4Chorus, we can submit a PR for Chorus that pulls the new Mecurial4Chorus package and makes the right changes in Chorus as well (like no longer messing with encodings in Program.cs).

Long story short, PR incoming to update to Mercurial 6.5.1.