12 Commits

Author SHA1 Message Date
Mark Nauwelaerts
426ed618b2 Release v1.0.4 2022-12-07 19:10:40 +01:00
Mark Nauwelaerts
5f34d049b9 test: adjust configuration to recent git
... to allow file protocol

Fixes mnauw/git-remote-hg#53
2022-12-06 22:57:29 +01:00
Mark Nauwelaerts
ea7e9bf31a helper: align getenv compatibility helper 2022-10-22 18:46:52 +02:00
Mark Nauwelaerts
a3a36883c5 Ensure fallback getenvb returns bytes 2022-10-22 18:46:47 +02:00
Jeremiah Blanchard
0fdd28319a Fixes bug where compat.getenv fails on Windows due to bytes type (when string expected) (tested on Python 3.10) 2022-10-22 18:28:04 +02:00
Julien Cristau
dfa3ad5fca helper: adjust for hg 6.1
mercurial.util.url became mercurial.utils.urlutil.url in 5.8.
2022-03-28 22:48:55 +02:00
Mark Nauwelaerts
ebd5bdb111 Release v1.0.3.2 2022-02-23 23:16:12 +01:00
Paul Wise
00ac711fb2 Fix syntax error caused by extra semicolon
Fixes: commit 4d38bff053
2022-02-23 23:15:30 +01:00
Mark Nauwelaerts
aadc899982 Release v1.0.3.1 2022-02-22 22:00:48 +01:00
Paul Wise
4d38bff053 Fail the build when Python with Mercurial is not available 2022-02-22 21:58:51 +01:00
Paul Wise
a8cd6a92b3 Do not overwrite found python executable with 'python' 2022-02-22 21:58:51 +01:00
Paul Wise
a08ad9d2b4 Add an option to test the pre-installed scripts
This is useful for distros like Debian that do tests on installed packages.

See-also: https://ci.debian.net/
2022-02-22 21:58:51 +01:00
5 changed files with 52 additions and 29 deletions

View File

@@ -14,9 +14,9 @@ build:
PYTHON=python2 ; \
elif python -c 'import mercurial' 2> /dev/null ; then \
PYTHON=python ; \
fi ; \
if [ -n "$$PYTHON" ] ; then \
PYTHON=python ; \
else \
echo 'Python with Mercurial not available' >&2 ; \
exit 1 ; \
fi ; \
mkdir -p bin ; \
for s in git-remote-hg git-hg-helper ; do \

View File

@@ -5,6 +5,11 @@
from mercurial import hg, ui, commands, util
from mercurial import context, subrepo
try:
# hg >= 5.8
from mercurial.utils import urlutil
except ImportError:
from mercurial import util as urlutil
import re
import sys
@@ -51,7 +56,13 @@ if sys.version_info[0] == 3:
stdout = sys.stdout.buffer
stderr = sys.stderr.buffer
getcwd = os.getcwdb
getenv = os.getenvb if os.supports_bytes_environ else os.getenv
@staticmethod
def getenvb(val, default):
result = os.getenv(val.decode(), default.decode() if hasattr(default, 'decode') else default)
# if result is a string, get bytes instead
result = result.encode() if hasattr(result, 'encode') else result
return result
getenv = os.getenvb if os.supports_bytes_environ else getenvb
else:
class compat(basecompat):
# life was simple in those days ...
@@ -308,11 +319,11 @@ class GitHgRepo:
if not kind in (b'hg', b'git'):
warn('skipping unsupported subrepo type %s' % kind)
continue
if not util.url(src).isabs():
if not urlutil.url(src).isabs():
parent = self.get_hg_repo_url(remote)
if not parent:
die(b'could not determine repo url of %s' % remote)
parent = util.url(parent)
parent = urlutil.url(parent)
parent.path = posixpath.join(parent.path or b'', src)
parent.path = posixpath.normpath(parent.path)
src = bytes(parent)

View File

@@ -86,7 +86,13 @@ if sys.version_info[0] == 3:
stdout = sys.stdout.buffer
stderr = sys.stderr.buffer
getcwd = os.getcwdb
getenv = os.getenvb if os.supports_bytes_environ else os.getenv
@staticmethod
def getenvb(val, default):
result = os.getenv(val.decode(), default.decode() if hasattr(default, 'decode') else default)
# if result is a string, get bytes instead
result = result.encode() if hasattr(result, 'encode') else result
return result
getenv = os.getenvb if os.supports_bytes_environ else getenvb
urlparse = urllib.parse.urlparse
urljoin = urllib.parse.urljoin
else:

View File

@@ -3,7 +3,7 @@
import setuptools
# strip leading v
version = 'v1.0.3'[1:]
version = 'v1.0.4'[1:]
# check for released version
assert (len(version) > 0)

View File

@@ -27,28 +27,33 @@ SHARNESS_BUILD_DIRECTORY="$(mktemp -d)"
export PATH="${PATH#*:}"
rmdir "$SHARNESS_BUILD_DIRECTORY"
if [ -n "$PYTHON" ] && "$PYTHON" -c 'import mercurial' 2> /dev/null ; then
: Use chosen Python version
elif python3 -c 'import mercurial' 2> /dev/null ; then
PYTHON=python3
elif python2 -c 'import mercurial' 2> /dev/null ; then
PYTHON=python2
elif python -c 'import mercurial' 2> /dev/null ; then
PYTHON=python
fi
if [ -n "$PYTHON" ] ; then
test_set_prereq PYTHON
if [ -z "$TEST_INSTALLED_SCRIPTS" ] ; then
if [ -n "$PYTHON" ] && "$PYTHON" -c 'import mercurial' 2> /dev/null ; then
: Use chosen Python version
elif python3 -c 'import mercurial' 2> /dev/null ; then
PYTHON=python3
elif python2 -c 'import mercurial' 2> /dev/null ; then
PYTHON=python2
elif python -c 'import mercurial' 2> /dev/null ; then
PYTHON=python
fi
if [ -n "$PYTHON" ] ; then
test_set_prereq PYTHON
# Change shebang on a copy of scripts to chosen Python version
TEST_BIN="$SHARNESS_TRASH_DIRECTORY/bin"
mkdir -p "$TEST_BIN"
for s in git-remote-hg git-hg-helper ; do
printf "%s\n" "#!/usr/bin/env $PYTHON" > "$TEST_BIN/$s"
tail -n +2 "$SHARNESS_TEST_DIRECTORY/../$s" >> "$TEST_BIN/$s"
chmod u+x "$TEST_BIN/$s"
done
export PATH="$TEST_BIN${PATH:+:$PATH}"
unset TEST_BIN
# Change shebang on a copy of scripts to chosen Python version
TEST_BIN="$SHARNESS_TRASH_DIRECTORY/bin"
mkdir -p "$TEST_BIN"
for s in git-remote-hg git-hg-helper ; do
printf "%s\n" "#!/usr/bin/env $PYTHON" > "$TEST_BIN/$s"
tail -n +2 "$SHARNESS_TEST_DIRECTORY/../$s" >> "$TEST_BIN/$s"
chmod u+x "$TEST_BIN/$s"
done
export PATH="$TEST_BIN${PATH:+:$PATH}"
unset TEST_BIN
fi
else
# The build/install process ensures Python is available
test_set_prereq PYTHON
fi
GIT_AUTHOR_EMAIL=author@example.com
@@ -60,3 +65,4 @@ export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
# maintain backwards compatible default
# (as used in remote helper)
git config --global init.defaultBranch master
git config --global protocol.file.allow always