Enable python3 support

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
Felipe Contreras
2022-08-05 19:54:53 -05:00
parent 34ba087896
commit b3b9b5de39
7 changed files with 29 additions and 19 deletions

View File

@@ -52,10 +52,7 @@ the same commits:
Remember to run `git gc --aggressive` after cloning a repository, especially if Remember to run `git gc --aggressive` after cloning a repository, especially if
it's a big one. Otherwise lots of space will be wasted. it's a big one. Otherwise lots of space will be wasted.
The newest supported version of Mercurial is 6.1 but only through Python 2. The The newest supported version of Mercurial is 6.2, the oldest one is 2.4.
oldest one is 2.4.
Support for Python 3 is ready, but will be released in the next version soon.
=== Pushing branches === === Pushing branches ===

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# #
# Copyright (c) 2012 Felipe Contreras # Copyright (c) 2012 Felipe Contreras
# #
@@ -26,6 +26,14 @@ import atexit
import hashlib import hashlib
import time as ptime import time as ptime
if sys.version_info[0] >= 3:
from urllib.parse import urlparse, urljoin
from urllib.parse import quote as urlquote, unquote as urlunquote
ferr = sys.stderr.buffer
fin = sys.stdin.buffer
else:
from urlparse import urlparse, urljoin from urlparse import urlparse, urljoin
from urllib import quote as urlquote, unquote as urlunquote from urllib import quote as urlquote, unquote as urlunquote
@@ -33,6 +41,9 @@ from urllib import quote as urlquote, unquote as urlunquote
reload(sys) reload(sys)
sys.setdefaultencoding('utf-8') sys.setdefaultencoding('utf-8')
ferr = sys.stderr
fin = sys.stdin
# #
# If you want to see Mercurial revisions as Git commit notes: # If you want to see Mercurial revisions as Git commit notes:
# git config core.notesRef refs/notes/hg # git config core.notesRef refs/notes/hg
@@ -223,7 +234,7 @@ class Parser:
self.line = self.get_line() self.line = self.get_line()
def get_line(self): def get_line(self):
return sys.stdin.readline().decode().strip() return fin.readline().decode().strip()
def __getitem__(self, i): def __getitem__(self, i):
return self.line.split()[i] return self.line.split()[i]
@@ -253,7 +264,7 @@ class Parser:
return None return None
i = self.line.index(' ') + 1 i = self.line.index(' ') + 1
size = int(self.line[i:]) size = int(self.line[i:])
return sys.stdin.read(size) return fin.read(size)
def get_author(self): def get_author(self):
ex = None ex = None
@@ -416,7 +427,7 @@ def get_repo(url, alias):
myui = ui.ui() myui = ui.ui()
myui.setconfig(b'ui', b'interactive', b'off') myui.setconfig(b'ui', b'interactive', b'off')
myui.fout = sys.stderr myui.fout = ferr
if get_config_bool('remote-hg.insecure'): if get_config_bool('remote-hg.insecure'):
myui.setconfig(b'web', b'cacerts', b'') myui.setconfig(b'web', b'cacerts', b'')

View File

@@ -17,7 +17,7 @@ then
test_done test_done
fi fi
if ! python2 -c 'import mercurial' > /dev/null 2>&1 if ! python -c 'import mercurial' > /dev/null 2>&1
then then
skip_all='skipping remote-hg tests; mercurial not available' skip_all='skipping remote-hg tests; mercurial not available'
test_done test_done

View File

@@ -17,16 +17,16 @@ then
test_done test_done
fi fi
if ! python2 -c 'import mercurial' > /dev/null 2>&1 if ! python -c 'import mercurial' > /dev/null 2>&1
then then
skip_all='skipping remote-hg tests; mercurial not available' skip_all='skipping remote-hg tests; mercurial not available'
test_done test_done
fi fi
if python2 -c 'import hggit' > /dev/null 2>&1 if python -c 'import hggit' > /dev/null 2>&1
then then
hggit=hggit hggit=hggit
elif python2 -c 'import hgext.git' > /dev/null 2>&1 elif python -c 'import hgext.git' > /dev/null 2>&1
then then
hggit=hgext.git hggit=hgext.git
else else

View File

@@ -17,7 +17,7 @@ then
test_done test_done
fi fi
if ! python2 -c 'import mercurial' > /dev/null 2>&1 if ! python -c 'import mercurial' > /dev/null 2>&1
then then
skip_all='skipping remote-hg tests; mercurial not available' skip_all='skipping remote-hg tests; mercurial not available'
test_done test_done

View File

@@ -102,7 +102,7 @@ class Component
def build def build
Dir.chdir(dir) do Dir.chdir(dir) do
targets = %w[build_py build_ext].map { |e| [e, '--build-lib', "#{$builddir}/python"] } targets = %w[build_py build_ext].map { |e| [e, '--build-lib', "#{$builddir}/python"] }
run_cmd %w[python2 setup.py --quiet] + targets.flatten run_cmd %w[python setup.py --quiet] + targets.flatten
end end
end end

View File

@@ -40,3 +40,5 @@ hg:5.5 hggit:0.9.0 dulwich:0.19.15 # 2020_08
hg:5.6 hggit:0.9.0 dulwich:0.19.15 # 2020_10 hg:5.6 hggit:0.9.0 dulwich:0.19.15 # 2020_10
hg:5.7 hggit:0.10.0 dulwich:0.19.16 # 2021_01 hg:5.7 hggit:0.10.0 dulwich:0.19.16 # 2021_01
hg:5.8 hggit:0.10.1 dulwich:0.20.0 # 2021_05 # python3