| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,12 +42,12 @@ | |||
| 42 | 42 | ) | |
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | - execute_kwargs = set(('istream', 'with_keep_cwd', 'with_extended_output', | ||
| 45 | + execute_kwargs = set(('istream', 'with_extended_output', | ||
| 46 | 46 | 'with_exceptions', 'as_process', 'stdout_as_string', | |
| 47 | 47 | 'output_stream', 'with_stdout', 'kill_after_timeout', | |
| 48 | 48 | 'universal_newlines', 'shell')) | |
| 49 | 49 | ||
| 50 | - log = logging.getLogger('git.cmd') | ||
| 50 | + log = logging.getLogger(__name__) | ||
| 51 | 51 | log.addHandler(logging.NullHandler()) | |
| 52 | 52 | ||
| 53 | 53 | __all__ = ('Git',) | |
@@ -418,7 +418,6 @@ def version_info(self): | |||
| 418 | 418 | ||
| 419 | 419 | def execute(self, command, | |
| 420 | 420 | istream=None, | |
| 421 | - with_keep_cwd=False, | ||
| 422 | 421 | with_extended_output=False, | |
| 423 | 422 | with_exceptions=True, | |
| 424 | 423 | as_process=False, | |
@@ -441,11 +440,6 @@ def execute(self, command, | |||
| 441 | 440 | :param istream: | |
| 442 | 441 | Standard input filehandle passed to subprocess.Popen. | |
| 443 | 442 | ||
| 444 | - :param with_keep_cwd: | ||
| 445 | - Whether to use the current working directory from os.getcwd(). | ||
| 446 | - The cmd otherwise uses its own working_dir that it has been initialized | ||
| 447 | - with if possible. | ||
| 448 | - | ||
| 449 | 443 | :param with_extended_output: | |
| 450 | 444 | Whether to return a (status, stdout, stderr) tuple. | |
| 451 | 445 | ||
@@ -518,10 +512,7 @@ def execute(self, command, | |||
| 518 | 512 | log.info(' '.join(command)) | |
| 519 | 513 | ||
| 520 | 514 | # Allow the user to have the command executed in their working dir. | |
| 521 | - if with_keep_cwd or self._working_dir is None: | ||
| 522 | - cwd = os.getcwd() | ||
| 523 | - else: | ||
| 524 | - cwd = self._working_dir | ||
| 515 | + cwd = self._working_dir or os.getcwd() | ||
| 525 | 516 | ||
| 526 | 517 | # Start the process | |
| 527 | 518 | env = os.environ.copy() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,8 +62,11 @@ | |||
| 62 | 62 | import os | |
| 63 | 63 | import sys | |
| 64 | 64 | import re | |
| 65 | + import logging | ||
| 65 | 66 | from collections import namedtuple | |
| 66 | 67 | ||
| 68 | + log = logging.getLogger(__name__) | ||
| 69 | + | ||
| 67 | 70 | DefaultDBType = GitCmdObjectDB | |
| 68 | 71 | if sys.version_info[:2] < (2, 5): # python 2.4 compatiblity | |
| 69 | 72 | DefaultDBType = GitCmdObjectDB | |
@@ -871,46 +874,15 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): | |||
| 871 | 874 | if progress is not None: | |
| 872 | 875 | progress = to_progress_instance(progress) | |
| 873 | 876 | ||
| 874 | - # special handling for windows for path at which the clone should be | ||
| 875 | - # created. | ||
| 876 | - # tilde '~' will be expanded to the HOME no matter where the ~ occours. Hence | ||
| 877 | - # we at least give a proper error instead of letting git fail | ||
| 878 | - prev_cwd = None | ||
| 879 | - prev_path = None | ||
| 880 | 877 | odbt = kwargs.pop('odbt', odb_default_type) | |
| 881 | - if is_win: | ||
| 882 | - if '~' in path: | ||
| 883 | - raise OSError("Git cannot handle the ~ character in path %r correctly" % path) | ||
| 884 | - | ||
| 885 | - # on windows, git will think paths like c: are relative and prepend the | ||
| 886 | - # current working dir ( before it fails ). We temporarily adjust the working | ||
| 887 | - # dir to make this actually work | ||
| 888 | - match = re.match("(\w:[/\\\])(.*)", path) | ||
| 889 | - if match: | ||
| 890 | - prev_cwd = os.getcwd() | ||
| 891 | - prev_path = path | ||
| 892 | - drive, rest_of_path = match.groups() | ||
| 893 | - os.chdir(drive) | ||
| 894 | - path = rest_of_path | ||
| 895 | - kwargs['with_keep_cwd'] = True | ||
| 896 | - # END cwd preparation | ||
| 897 | - # END windows handling | ||
| 898 | - | ||
| 899 | - try: | ||
| 900 | - proc = git.clone(url, path, with_extended_output=True, as_process=True, | ||
| 901 | - v=True, **add_progress(kwargs, git, progress)) | ||
| 902 | - if progress: | ||
| 903 | - handle_process_output(proc, None, progress.new_message_handler(), finalize_process) | ||
| 904 | - else: | ||
| 905 | - (stdout, stderr) = proc.communicate() # FIXME: Will block of outputs are big! | ||
| 906 | - finalize_process(proc, stderr=stderr) | ||
| 907 | - # end handle progress | ||
| 908 | - finally: | ||
| 909 | - if prev_cwd is not None: | ||
| 910 | - os.chdir(prev_cwd) | ||
| 911 | - path = prev_path | ||
| 912 | - # END reset previous working dir | ||
| 913 | - # END bad windows handling | ||
| 878 | + proc = git.clone(url, path, with_extended_output=True, as_process=True, | ||
| 879 | + v=True, **add_progress(kwargs, git, progress)) | ||
| 880 | + if progress: | ||
| 881 | + handle_process_output(proc, None, progress.new_message_handler(), finalize_process) | ||
| 882 | + else: | ||
| 883 | + (stdout, stderr) = proc.communicate() # FIXME: Will block of outputs are big! | ||
| 884 | + log.debug("Cmd(%s)'s unused stdout: %s", getattr(proc, 'args', ''), stdout) | ||
| 885 | + finalize_process(proc, stderr=stderr) | ||
| 914 | 886 | ||
| 915 | 887 | # our git command could have a different working dir than our actual | |
| 916 | 888 | # environment, hence we prepend its working dir if required | |
@@ -922,7 +894,7 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): | |||
| 922 | 894 | # that contains the remote from which we were clones, git stops liking it | |
| 923 | 895 | # as it will escape the backslashes. Hence we undo the escaping just to be | |
| 924 | 896 | # sure | |
| 925 | - repo = cls(os.path.abspath(path), odbt=odbt) | ||
| 897 | + repo = cls(path, odbt=odbt) | ||
| 926 | 898 | if repo.remotes: | |
| 927 | 899 | with repo.remotes[0].config_writer as writer: | |
| 928 | 900 | writer.set_value('url', repo.remotes[0].url.replace("\\\\", "\\").replace("\\", "/")) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments