mirror of
				https://github.com/mnauw/git-remote-hg.git
				synced 2025-10-31 16:45:48 +01:00 
			
		
		
		
	Compare commits
	
		
			28 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 426ed618b2 | ||
|  | 5f34d049b9 | ||
|  | ea7e9bf31a | ||
|  | a3a36883c5 | ||
|  | 0fdd28319a | ||
|  | dfa3ad5fca | ||
|  | ebd5bdb111 | ||
|  | 00ac711fb2 | ||
|  | aadc899982 | ||
|  | 4d38bff053 | ||
|  | a8cd6a92b3 | ||
|  | a08ad9d2b4 | ||
|  | 8c08b6de21 | ||
|  | 949345fb11 | ||
|  | 0d49f75131 | ||
|  | 7159e4a030 | ||
|  | cdcd70b453 | ||
|  | f5c38f3a59 | ||
|  | 3b11156e69 | ||
|  | afc1f3a2c2 | ||
|  | e596a5f457 | ||
|  | ec654d4682 | ||
|  | 7913920a97 | ||
|  | da60201ae3 | ||
|  | 704869df29 | ||
|  | 5769e965eb | ||
|  | 1ee28bd233 | ||
|  | 1796289df3 | 
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| /build/ | ||||
| /dist/ | ||||
| /git_remote_hg.egg-info/ | ||||
							
								
								
									
										31
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								Makefile
									
									
									
									
									
								
							| @@ -3,7 +3,28 @@ prefix := $(HOME) | ||||
| bindir := $(prefix)/bin | ||||
| mandir := $(prefix)/share/man/man1 | ||||
|  | ||||
| all: doc | ||||
| all: build doc | ||||
|  | ||||
| build: | ||||
| 	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 ; \ | ||||
| 	else \ | ||||
| 		echo 'Python with Mercurial not available' >&2 ; \ | ||||
| 		exit 1 ; \ | ||||
| 	fi ; \ | ||||
| 	mkdir -p bin ; \ | ||||
| 	for s in git-remote-hg git-hg-helper ; do \ | ||||
| 		printf "%s\n" "#!/usr/bin/env $$PYTHON" > "bin/$$s" ; \ | ||||
| 		tail -n +2 "./$$s" >> "bin/$$s" ; \ | ||||
| 		chmod 755 "bin/$$s" ; \ | ||||
| 		touch -r "./$$s" "bin/$$s" ; \ | ||||
| 	done | ||||
|  | ||||
| doc: doc/git-remote-hg.1 | ||||
|  | ||||
| @@ -15,12 +36,14 @@ doc/git-remote-hg.1: doc/git-remote-hg.txt | ||||
|  | ||||
| clean: | ||||
| 	$(RM) doc/git-remote-hg.1 | ||||
| 	$(RM) -r bin/ | ||||
|  | ||||
| D = $(DESTDIR) | ||||
|  | ||||
| install: | ||||
| install: build | ||||
| 	install -d -m 755 $(D)$(bindir)/ | ||||
| 	install -m 755 git-remote-hg $(D)$(bindir)/git-remote-hg | ||||
| 	install -m 755 bin/git-remote-hg $(D)$(bindir)/git-remote-hg | ||||
| 	install -m 755 bin/git-hg-helper $(D)$(bindir)/git-hg-helper | ||||
|  | ||||
| install-doc: doc | ||||
| 	install -d -m 755 $(D)$(mandir)/ | ||||
| @@ -38,4 +61,4 @@ pypi-upload: | ||||
| pypi-test: | ||||
| 	twine upload --repository-url https://test.pypi.org/legacy/ dist/* | ||||
|  | ||||
| .PHONY: all test install install-doc clean pypy pypy-upload | ||||
| .PHONY: all build test install install-doc clean pypy pypy-upload | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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: | ||||
| @@ -193,7 +199,9 @@ def gitref(ref): | ||||
|     # standard url percentage encoding with a (legacy) twist: | ||||
|     # ' ' -> '___' | ||||
|     # '___' also percentage encoded | ||||
|     return compat.urlquote(ref).replace(b'___', b'%5F%5F%5F').replace(b'%20', b'___') | ||||
|     # python 3.6 considers ~ reserved, whereas python 3.7 no longer | ||||
|     return compat.urlquote(ref).replace(b'___', b'%5F%5F%5F'). \ | ||||
|         replace(b'%20', b'___').replace(b'~', b'%7E') | ||||
|  | ||||
| def check_version(*check): | ||||
|     if not hg_version: | ||||
|   | ||||
							
								
								
									
										5
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								setup.py
									
									
									
									
									
								
							| @@ -1,12 +1,9 @@ | ||||
| # git-remote-hg setuptools script | ||||
|  | ||||
| import setuptools | ||||
| import subprocess | ||||
| import sys | ||||
| import os | ||||
|  | ||||
| # strip leading v | ||||
| version = 'v1.0.2.1'[1:] | ||||
| version = 'v1.0.4'[1:] | ||||
|  | ||||
| # check for released version | ||||
| assert (len(version) > 0) | ||||
|   | ||||
| @@ -13,13 +13,7 @@ test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/ | ||||
|  | ||||
| if ! test_have_prereq PYTHON | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; python not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
| if ! python -c 'import mercurial' > /dev/null 2>&1 | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; mercurial not available' | ||||
| 	skip_all='skipping remote-hg tests; python with mercurial not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
|   | ||||
| @@ -13,13 +13,7 @@ test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/ | ||||
|  | ||||
| if ! test_have_prereq PYTHON | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; python not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
| if ! python -c 'import mercurial' > /dev/null 2>&1 | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; mercurial not available' | ||||
| 	skip_all='skipping remote-hg tests; python with mercurial not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
|   | ||||
| @@ -13,20 +13,14 @@ test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/ | ||||
|  | ||||
| if ! test_have_prereq PYTHON | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; python not available' | ||||
| 	skip_all='skipping remote-hg tests; python with mercurial not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
| if ! python -c 'import mercurial' > /dev/null 2>&1 | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; mercurial not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
| if python -c 'import hggit' > /dev/null 2>&1 | ||||
| if "$PYTHON" -c 'import hggit' > /dev/null 2>&1 | ||||
| then | ||||
| 	hggit=hggit | ||||
| elif python -c 'import hgext.git' > /dev/null 2>&1 | ||||
| elif "$PYTHON" -c 'import hgext.git' > /dev/null 2>&1 | ||||
| then | ||||
| 	hggit=hgext.git | ||||
| else | ||||
|   | ||||
| @@ -270,10 +270,10 @@ test_expect_success 'push with renamed executable preserves executable bit' ' | ||||
| 	) && | ||||
|  | ||||
| 	( | ||||
| 	umask 0 && | ||||
| 	cd hgrepo && | ||||
| 	hg update && | ||||
| 	stat content2 >expected && | ||||
| 	# umask mileage might vary | ||||
| 	grep -- -r.xr.xr.x expected | ||||
| 	) | ||||
| ' | ||||
|   | ||||
							
								
								
									
										11
									
								
								test/main.t
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								test/main.t
									
									
									
									
									
								
							| @@ -22,13 +22,7 @@ fi | ||||
|  | ||||
| if ! test_have_prereq PYTHON | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; python not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
| if ! python -c 'import mercurial' > /dev/null 2>&1 | ||||
| then | ||||
| 	skip_all='skipping remote-hg tests; mercurial not available' | ||||
| 	skip_all='skipping remote-hg tests; python with mercurial not available' | ||||
| 	test_done | ||||
| fi | ||||
|  | ||||
| @@ -803,7 +797,6 @@ test_expect_success 'remote big push force' ' | ||||
| 	fi | ||||
| 	) && | ||||
|  | ||||
| 	check_branch hgrepo default six && | ||||
| 	check_branch hgrepo good_branch eight && | ||||
| 	check_branch hgrepo bad_branch nine && | ||||
| 	check_branch hgrepo new_branch ten && | ||||
| @@ -1093,7 +1086,7 @@ test_expect_success 'push bookmark without changesets' ' | ||||
| 	check_bookmark hgrepo feature-a two | ||||
| ' | ||||
|  | ||||
| test_expect_unstable 'pull tags' ' | ||||
| test_expect_success 'pull tags' ' | ||||
| 	test_when_finished "rm -rf hgrepo gitrepo" && | ||||
|  | ||||
| 	( | ||||
|   | ||||
| @@ -1,8 +1,60 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| . ./sharness.sh | ||||
| if [ -z "$SHARNESS" ] ; then | ||||
| 	for d in \ | ||||
| 		"." \ | ||||
| 		"$HOME/share/sharness" \ | ||||
| 		"/usr/local/share/sharness" \ | ||||
| 		"/usr/share/sharness" | ||||
| 	do | ||||
| 		f="$d/sharness.sh" | ||||
| 		if [ -f "$f" ] ; then | ||||
| 			SHARNESS="$f" | ||||
| 		fi | ||||
| 	done | ||||
| fi | ||||
| if [ -z "$SHARNESS" ] || [ ! -f "$SHARNESS" ] ; then | ||||
| 	echo "sharness.sh not found" >&2 | ||||
| 	exit 1 | ||||
| fi | ||||
|  | ||||
| test_set_prereq PYTHON | ||||
| # Prevent sharness from adding the source directory to PATH | ||||
| # since the scripts use unversioned python for their shebang | ||||
| # but tests should run under the python with mercurial support | ||||
| # so create an empty directory and strip it from PATH afterwards | ||||
| SHARNESS_BUILD_DIRECTORY="$(mktemp -d)" | ||||
| . "$SHARNESS" | ||||
| export PATH="${PATH#*:}" | ||||
| rmdir "$SHARNESS_BUILD_DIRECTORY" | ||||
|  | ||||
| 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 | ||||
| 	fi | ||||
| else | ||||
| 	# The build/install process ensures Python is available | ||||
| 	test_set_prereq PYTHON | ||||
| fi | ||||
|  | ||||
| GIT_AUTHOR_EMAIL=author@example.com | ||||
| GIT_AUTHOR_NAME='A U Thor' | ||||
| @@ -10,3 +62,7 @@ GIT_COMMITTER_EMAIL=committer@example.com | ||||
| GIT_COMMITTER_NAME='C O Mitter' | ||||
| export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME | ||||
| 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 | ||||
|   | ||||
| @@ -20,11 +20,17 @@ | ||||
| # | ||||
|  | ||||
| require 'fileutils' | ||||
| require 'tmpdir' | ||||
|  | ||||
| $tests = %w[main.t bidi.t hg-git.t] | ||||
| $workdir = "#{Dir.home}/.cache/git-remote-hg" | ||||
| $builddir = "/tmp/git-remote-hg-build" | ||||
| $testoutdir = "/tmp/git-remote-hg-tests" | ||||
| $builddir = Dir.mktmpdir("git-remote-hg-build-") | ||||
| $testoutdir = Dir.mktmpdir("git-remote-hg-tests-") | ||||
|  | ||||
| at_exit { | ||||
|   FileUtils.remove_entry($builddir) | ||||
|   FileUtils.remove_entry($testoutdir) | ||||
| } | ||||
|  | ||||
| QUIET, LOW, HIGH = (1..3).to_a | ||||
| $verbosity = LOW | ||||
|   | ||||
		Reference in New Issue
	
	Block a user