From 8ea7e265d1549613c12cbe42a2e012527c1a97e4 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Sat, 1 Oct 2016 20:14:50 +0200 Subject: repo, cmd: DROP UNEEDED Win path for chcwd & check for '~' homedir + Do not abspath twice when contructing cloned repo. + Add `git.repo.base` logger. --- git/repo/base.py | 52 ++++++++++++---------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) (limited to 'git/repo/base.py') diff --git a/git/repo/base.py b/git/repo/base.py index 8b68b5ff..4e9549ee 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -62,8 +62,11 @@ from git.compat import ( import os import sys import re +import logging from collections import namedtuple +log = logging.getLogger(__name__) + DefaultDBType = GitCmdObjectDB if sys.version_info[:2] < (2, 5): # python 2.4 compatiblity DefaultDBType = GitCmdObjectDB @@ -871,46 +874,15 @@ class Repo(object): if progress is not None: progress = to_progress_instance(progress) - # special handling for windows for path at which the clone should be - # created. - # tilde '~' will be expanded to the HOME no matter where the ~ occours. Hence - # we at least give a proper error instead of letting git fail - prev_cwd = None - prev_path = None odbt = kwargs.pop('odbt', odb_default_type) - if is_win: - if '~' in path: - raise OSError("Git cannot handle the ~ character in path %r correctly" % path) - - # on windows, git will think paths like c: are relative and prepend the - # current working dir ( before it fails ). We temporarily adjust the working - # dir to make this actually work - match = re.match("(\w:[/\\\])(.*)", path) - if match: - prev_cwd = os.getcwd() - prev_path = path - drive, rest_of_path = match.groups() - os.chdir(drive) - path = rest_of_path - kwargs['with_keep_cwd'] = True - # END cwd preparation - # END windows handling - - try: - proc = git.clone(url, path, with_extended_output=True, as_process=True, - v=True, **add_progress(kwargs, git, progress)) - if progress: - handle_process_output(proc, None, progress.new_message_handler(), finalize_process) - else: - (stdout, stderr) = proc.communicate() # FIXME: Will block of outputs are big! - finalize_process(proc, stderr=stderr) - # end handle progress - finally: - if prev_cwd is not None: - os.chdir(prev_cwd) - path = prev_path - # END reset previous working dir - # END bad windows handling + proc = git.clone(url, path, with_extended_output=True, as_process=True, + v=True, **add_progress(kwargs, git, progress)) + if progress: + handle_process_output(proc, None, progress.new_message_handler(), finalize_process) + else: + (stdout, stderr) = proc.communicate() # FIXME: Will block of outputs are big! + log.debug("Cmd(%s)'s unused stdout: %s", getattr(proc, 'args', ''), stdout) + finalize_process(proc, stderr=stderr) # our git command could have a different working dir than our actual # environment, hence we prepend its working dir if required @@ -922,7 +894,7 @@ class Repo(object): # that contains the remote from which we were clones, git stops liking it # as it will escape the backslashes. Hence we undo the escaping just to be # sure - repo = cls(os.path.abspath(path), odbt=odbt) + repo = cls(path, odbt=odbt) if repo.remotes: with repo.remotes[0].config_writer as writer: writer.set_value('url', repo.remotes[0].url.replace("\\\\", "\\").replace("\\", "/")) -- cgit v1.2.1 From 4b586fbb94d5acc6e06980a8a96f66771280beda Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Tue, 4 Oct 2016 14:29:28 +0200 Subject: daemon, #525: FIX remote urls in config-files + Parse most remote & config-urls \-->/. + Used relative daemon-paths. + Use git-daemon PORT above 10k; on Windows all below need Admin rights. +FIXED git-daemon @with_rw_and_rw_remote_repo(): + test_base.test_with_rw_remote_and_rw_repo() PASS. + test_remote.test_base() now freezes! (so still hidden win_err) + repo_test: minor finally delete test-repos created inside this repo. + util: delete unused `absolute_project_path()`. --- git/repo/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/repo/base.py') diff --git a/git/repo/base.py b/git/repo/base.py index 4e9549ee..c5cdce7c 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -897,7 +897,7 @@ class Repo(object): repo = cls(path, odbt=odbt) if repo.remotes: with repo.remotes[0].config_writer as writer: - writer.set_value('url', repo.remotes[0].url.replace("\\\\", "\\").replace("\\", "/")) + writer.set_value('url', Git.polish_url(repo.remotes[0].url)) # END handle remote repo return repo -- cgit v1.2.1