Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ea7e26

Browse files
committed
repo, cmd: DROP UNEEDED Win path for chcwd & check for '~' homedir
+ Do not abspath twice when contructing cloned repo.+ Add `git.repo.base` logger.
1 parente316575 commit8ea7e26

File tree

2 files changed

+15
-52
lines changed

2 files changed

+15
-52
lines changed

‎git/cmd.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
)
4343

4444

45-
execute_kwargs=set(('istream','with_keep_cwd','with_extended_output',
45+
execute_kwargs=set(('istream','with_extended_output',
4646
'with_exceptions','as_process','stdout_as_string',
4747
'output_stream','with_stdout','kill_after_timeout',
4848
'universal_newlines','shell'))
4949

50-
log=logging.getLogger('git.cmd')
50+
log=logging.getLogger(__name__)
5151
log.addHandler(logging.NullHandler())
5252

5353
__all__= ('Git',)
@@ -418,7 +418,6 @@ def version_info(self):
418418

419419
defexecute(self,command,
420420
istream=None,
421-
with_keep_cwd=False,
422421
with_extended_output=False,
423422
with_exceptions=True,
424423
as_process=False,
@@ -441,11 +440,6 @@ def execute(self, command,
441440
:param istream:
442441
Standard input filehandle passed to subprocess.Popen.
443442
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-
449443
:param with_extended_output:
450444
Whether to return a (status, stdout, stderr) tuple.
451445
@@ -518,10 +512,7 @@ def execute(self, command,
518512
log.info(' '.join(command))
519513

520514
# Allow the user to have the command executed in their working dir.
521-
ifwith_keep_cwdorself._working_dirisNone:
522-
cwd=os.getcwd()
523-
else:
524-
cwd=self._working_dir
515+
cwd=self._working_diroros.getcwd()
525516

526517
# Start the process
527518
env=os.environ.copy()

‎git/repo/base.py

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@
6262
importos
6363
importsys
6464
importre
65+
importlogging
6566
fromcollectionsimportnamedtuple
6667

68+
log=logging.getLogger(__name__)
69+
6770
DefaultDBType=GitCmdObjectDB
6871
ifsys.version_info[:2]< (2,5):# python 2.4 compatiblity
6972
DefaultDBType=GitCmdObjectDB
@@ -871,46 +874,15 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
871874
ifprogressisnotNone:
872875
progress=to_progress_instance(progress)
873876

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
880877
odbt=kwargs.pop('odbt',odb_default_type)
881-
ifis_win:
882-
if'~'inpath:
883-
raiseOSError("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-
ifmatch:
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-
ifprogress:
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-
ifprev_cwdisnotNone:
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+
ifprogress:
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)
914886

915887
# our git command could have a different working dir than our actual
916888
# environment, hence we prepend its working dir if required
@@ -922,7 +894,7 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
922894
# that contains the remote from which we were clones, git stops liking it
923895
# as it will escape the backslashes. Hence we undo the escaping just to be
924896
# sure
925-
repo=cls(os.path.abspath(path),odbt=odbt)
897+
repo=cls(path,odbt=odbt)
926898
ifrepo.remotes:
927899
withrepo.remotes[0].config_writeraswriter:
928900
writer.set_value('url',repo.remotes[0].url.replace("\\\\","\\").replace("\\","/"))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp