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

Commitc80d727

Browse files
committed
Bumped version, updated changelog, reduced code smell
There is more work to do though, as many imports are still incorrect.Also, there are still print statements
1 parent965a08c commitc80d727

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+157
-165
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ New BSD License. See the LICENSE file.
6666
###DEVELOPMENT STATUS
6767

6868
[![Build Status](https://travis-ci.org/gitpython-developers/GitPython.svg?branch=0.3)](https://travis-ci.org/gitpython-developers/GitPython)
69-
[![Coverage Status](https://coveralls.io/repos/gitpython-developers/GitPython/badge.png)](https://coveralls.io/r/gitpython-developers/GitPython)
69+
[![Coverage Status](https://coveralls.io/repos/gitpython-developers/GitPython/badge.png?branch=0.3)](https://coveralls.io/r/gitpython-developers/GitPython?branch=0.3)
7070
[![Documentation Status](https://readthedocs.org/projects/gitpython/badge/?version=stable)](https://readthedocs.org/projects/gitpython/?badge=stable)
7171

7272

‎VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.2.1
1+
0.3.3

‎doc/source/changes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Changelog
55
0.3.3
66
=====
77
* When fetching, pulling or pushing, and an error occours, it will not be reported on stdout anymore. However, if there is a fatal error, it will still result in a GitCommandError to be thrown. This goes hand in hand with improved fetch result parsing.
8+
* Code Cleanup (in preparation for python 3 support)
9+
* Applied autopep8 and cleaned up code
10+
* Using python logging module instead of print statments to signal certain kinds of errors
811

912
0.3.2.1
1013
=======

‎git/cmd.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def execute(self, command,
334334
If you add additional keyword arguments to the signature of this method,
335335
you must update the execute_kwargs tuple housed in this module."""
336336
ifself.GIT_PYTHON_TRACEand (self.GIT_PYTHON_TRACE!='full'oras_process):
337-
print' '.join(command)
337+
print(' '.join(command))
338338

339339
# Allow the user to have the command executed in their working dir.
340340
ifwith_keep_cwdorself._working_dirisNone:
@@ -389,11 +389,11 @@ def execute(self, command,
389389
ifself.GIT_PYTHON_TRACE=='full':
390390
cmdstr=" ".join(command)
391391
ifstderr_value:
392-
print"%s -> %d; stdout: '%s'; stderr: '%s'"% (cmdstr,status,stdout_value,stderr_value)
392+
print("%s -> %d; stdout: '%s'; stderr: '%s'"% (cmdstr,status,stdout_value,stderr_value))
393393
elifstdout_value:
394-
print"%s -> %d; stdout: '%s'"% (cmdstr,status,stdout_value)
394+
print("%s -> %d; stdout: '%s'"% (cmdstr,status,stdout_value))
395395
else:
396-
print"%s -> %d"% (cmdstr,status)
396+
print("%s -> %d"% (cmdstr,status))
397397
# END handle debug printing
398398

399399
ifwith_exceptionsandstatus!=0:
@@ -522,14 +522,16 @@ def make_call():
522522
raise
523523
# END handle overridden variable
524524
type(self).GIT_PYTHON_GIT_EXECUTABLE=self.git_exec_name_win
525-
call= [self.GIT_PYTHON_GIT_EXECUTABLE]+list(args)
526525

527526
try:
528527
returnself.execute(make_call(),**_kwargs)
529528
finally:
530529
importwarnings
531-
msg="WARNING: Automatically switched to use git.cmd as git executable, which reduces performance by ~70%."
532-
msg+="Its recommended to put git.exe into the PATH or to set the %s environment variable to the executable's location"%self._git_exec_env_var
530+
msg="WARNING: Automatically switched to use git.cmd as git executable"
531+
msg+=", which reduces performance by ~70%."
532+
msg+="Its recommended to put git.exe into the PATH or to "
533+
msg+="set the %s "%self._git_exec_env_var
534+
msg+="environment variable to the executable's location"
533535
warnings.warn(msg)
534536
# END print of warning
535537
# END catch first failure

‎git/config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
configuration files"""
88

99
importre
10-
importos
1110
importConfigParserascp
1211
importinspect
13-
importcStringIO
1412

1513
fromgit.odictimportOrderedDict
1614
fromgit.utilimportLockFile
@@ -188,8 +186,8 @@ def __del__(self):
188186
try:
189187
try:
190188
self.write()
191-
exceptIOError,e:
192-
print"Exception during destruction of GitConfigParser: %s"%str(e)
189+
exceptIOErrorase:
190+
print("Exception during destruction of GitConfigParser: %s"%str(e))
193191
finally:
194192
self._lock._release_lock()
195193

@@ -287,7 +285,7 @@ def read(self):
287285
try:
288286
fp=open(file_object)
289287
close_fp=True
290-
exceptIOError,e:
288+
exceptIOError:
291289
continue
292290
# END fp handling
293291

‎git/diff.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
importre
88
fromobjects.blobimportBlob
99
fromobjects.utilimportmode_str_to_int
10-
fromexcimportGitCommandError
1110

1211
fromgitdb.utilimporthex_to_bin
1312

@@ -106,7 +105,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
106105
diff_method=Diff._index_from_patch_format
107106
index=diff_method(self.repo,proc.stdout)
108107

109-
status=proc.wait()
108+
proc.wait()
110109
returnindex
111110

112111

@@ -321,7 +320,7 @@ def _index_from_raw_format(cls, repo, stream):
321320
modify, delete and add files
322321
:return: git.DiffIndex"""
323322
# handles
324-
# :100644 1006446870991011cc8d9853a7a8a6f02061512c6a8190 37c5e30c879213e9ae83b21e9d11e55fc20c54b7 M .gitignore
323+
# :100644 100644687099101... 37c5e30c8... M .gitignore
325324
index=DiffIndex()
326325
forlineinstream:
327326
ifnotline.startswith(":"):

‎git/ext/gitdb

Submodulegitdb updated39 files

‎git/index/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Initialize the index package"""
22

3-
frombaseimport*
4-
fromtypimport*
3+
from __future__importabsolute_import
4+
5+
from .baseimport*
6+
from .typimport*

‎git/index/base.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
git_working_dir
2525
)
2626

27-
importgit.objects
2827
importgit.diffasdiff
2928

3029
fromgit.excimport (
@@ -43,13 +42,11 @@
4342
fromgit.objects.utilimportSerializable
4443

4544
fromgit.utilimport (
46-
IndexFileSHA1Writer,
4745
LazyMixin,
4846
LockedFD,
4947
join_path_native,
5048
file_contents_ro,
5149
to_native_path_linux,
52-
to_native_path
5350
)
5451

5552
fromfunimport (
@@ -418,9 +415,6 @@ def iter_blobs(self, predicate=lambda t: True):
418415
iterator. A default filter, the BlobFilter, allows you to yield blobs
419416
only if they match a given list of paths. """
420417
forentryinself.entries.itervalues():
421-
# TODO: is it necessary to convert the mode ? We did that when adding
422-
# it to the index, right ?
423-
mode=stat_mode_to_index_mode(entry.mode)
424418
blob=entry.to_blob(self.repo)
425419
blob.size=entry.size
426420
output= (entry.stage,blob)
@@ -602,7 +596,7 @@ def _entries_for_paths(self, paths, path_rewriter, fprogress, entries):
602596
defadd(self,items,force=True,fprogress=lambda*args:None,path_rewriter=None,
603597
write=True):
604598
"""Add files from the working tree, specific blobs or BaseIndexEntries
605-
to the index.
599+
to the index.
606600
607601
:param items:
608602
Multiple types of items are supported, types can be mixed within one call.
@@ -630,7 +624,7 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
630624
must be a path relative to our repository.
631625
632626
If their sha is null ( 40*0 ), their path must exist in the file system
633-
relative to the git repository as an object will be created from
627+
relative to the git repository as an object will be created from
634628
the data at the path.
635629
The handling now very much equals the way string paths are processed, except that
636630
the mode you have set will be kept. This allows you to create symlinks
@@ -892,7 +886,8 @@ def commit(self, message, parent_commits=None, head=True, author=None, committer
892886
:return:
893887
Commit object representing the new commit"""
894888
tree=self.write_tree()
895-
returnCommit.create_from_tree(self.repo,tree,message,parent_commits,head,author=author,committer=committer)
889+
returnCommit.create_from_tree(self.repo,tree,message,parent_commits,
890+
head,author=author,committer=committer)
896891

897892
@classmethod
898893
def_flush_stdin_and_wait(cls,proc,ignore_stdout=False):
@@ -995,7 +990,8 @@ def handle_stderr(proc, iter_checked_out_files):
995990
iffailed_files:
996991
valid_files=list(set(iter_checked_out_files)-set(failed_files))
997992
raiseCheckoutError(
998-
"Some files could not be checked out from the index due to local modifications",failed_files,valid_files,failed_reasons)
993+
"Some files could not be checked out from the index due to local modifications",
994+
failed_files,valid_files,failed_reasons)
999995
# END stderr handler
1000996

1001997
ifpathsisNone:

‎git/index/fun.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
S_IFDIR,
66
S_IFLNK,
77
S_ISLNK,
8-
S_IFDIR,
98
S_ISDIR,
109
S_IFMT,
1110
S_IFREG,
@@ -146,7 +145,7 @@ def read_cache(stream):
146145
path=read(path_size)
147146

148147
real_size= ((tell()-beginoffset+8)&~7)
149-
data=read((beginoffset+real_size)-tell())
148+
read((beginoffset+real_size)-tell())
150149
entry=IndexEntry((mode,sha,flags,path,ctime,mtime,dev,ino,uid,gid,size))
151150
# entry_key would be the method to use, but we safe the effort
152151
entries[(path,entry.stage)]=entry
@@ -160,8 +159,8 @@ def read_cache(stream):
160159
# 4 bytes length of chunk
161160
# repeated 0 - N times
162161
extension_data=stream.read(~0)
163-
assertlen(extension_data)>19,"Index Footer was not at least a sha on content as it was only %i bytes in size"%len(
164-
extension_data)
162+
assertlen(extension_data)>19,"Index Footer was not at least a sha on content as it was only %i bytes in size"\
163+
%len(extension_data)
165164

166165
content_sha=extension_data[-20:]
167166

@@ -265,7 +264,7 @@ def aggressive_tree_merge(odb, tree_shas):
265264
# it exists in all branches, if it was changed in both
266265
# its a conflict, otherwise we take the changed version
267266
# This should be the most common branch, so it comes first
268-
if(base[0]!=ours[0]andbase[0]!=theirs[0]andours[0]!=theirs[0])or \
267+
if(base[0]!=ours[0]andbase[0]!=theirs[0]andours[0]!=theirs[0])or \
269268
(base[1]!=ours[1]andbase[1]!=theirs[1]andours[1]!=theirs[1]):
270269
# changed by both
271270
out_append(_tree_entry_to_baseindexentry(base,1))

‎git/index/typ.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,5 @@ def from_base(cls, base):
172172
deffrom_blob(cls,blob,stage=0):
173173
""":return: Minimal entry resembling the given blob object"""
174174
time=pack(">LL",0,0)
175-
returnIndexEntry((blob.mode,blob.binsha,stage<<CE_STAGESHIFT,blob.path,time,time,0,0,0,0,blob.size))
175+
returnIndexEntry((blob.mode,blob.binsha,stage<<CE_STAGESHIFT,blob.path,
176+
time,time,0,0,0,0,blob.size))

‎git/objects/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
"""
22
Import all submodules main classes into the package space
33
"""
4+
from __future__importabsolute_import
45
importinspect
5-
frombaseimport*
6+
from.baseimport*
67
# Fix import dependency - add IndexObject to the util module, so that it can be
78
# imported by the submodule.base
8-
importsubmodule.util
9-
submodule.util.IndexObject=IndexObject
10-
submodule.util.Object=Object
11-
fromsubmodule.baseimport*
12-
fromsubmodule.rootimport*
9+
from .submoduleimportutil
10+
util.IndexObject=IndexObject
11+
util.Object=Object
12+
from.submodule.baseimport*
13+
from.submodule.rootimport*
1314

1415
# must come after submodule was made available
15-
fromtagimport*
16-
fromblobimport*
17-
fromcommitimport*
18-
fromtreeimport*
16+
from.tagimport*
17+
from.blobimport*
18+
from.commitimport*
19+
from.treeimport*
1920

2021
__all__= [nameforname,objinlocals().items()
2122
ifnot (name.startswith('_')orinspect.ismodule(obj))]

‎git/objects/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
fromgit.utilimportLazyMixin,join_path_native,stream_copy
77
fromutilimportget_object_type_by_name
88
fromgitdb.utilimport (
9-
hex_to_bin,
109
bin_to_hex,
1110
basename
1211
)

‎git/objects/commit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False,
276276
If True, the HEAD will be advanced to the new commit automatically.
277277
Else the HEAD will remain pointing on the previous commit. This could
278278
lead to undesired results when diffing files.
279-
:param author: The name of the author, optional. If unset, the repository
279+
:param author: The name of the author, optional. If unset, the repository
280280
configuration is used to obtain this value.
281-
:param committer: The name of the committer, optional. If unset, the
281+
:param committer: The name of the committer, optional. If unset, the
282282
repository configuration is used to obtain this value.
283283
284284
:return: Commit object representing the new commit

‎git/objects/submodule/base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
importos
3030
importsys
31-
importtime
3231

3332
__all__= ["Submodule","UpdateProgress"]
3433

@@ -140,7 +139,8 @@ def __str__(self):
140139
returnself._name
141140

142141
def__repr__(self):
143-
return"git.%s(name=%s, path=%s, url=%s, branch_path=%s)"% (type(self).__name__,self._name,self.path,self.url,self.branch_path)
142+
return"git.%s(name=%s, path=%s, url=%s, branch_path=%s)"\
143+
% (type(self).__name__,self._name,self.path,self.url,self.branch_path)
144144

145145
@classmethod
146146
def_config_parser(cls,repo,parent_commit,read_only):
@@ -236,7 +236,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
236236

237237
# assure we never put backslashes into the url, as some operating systems
238238
# like it ...
239-
ifurl!=None:
239+
ifurlisnotNone:
240240
url=to_native_path_linux(url)
241241
# END assure url correctness
242242

@@ -449,7 +449,8 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
449449
# handles dry_run
450450
ifmrepoisnotNoneandmrepo.head.commit.binsha!=binsha:
451451
progress.update(BEGIN|UPDWKTREE,0,1,prefix+
452-
"Updating working tree at %s for submodule %r to revision %s"% (self.path,self.name,hexsha))
452+
"Updating working tree at %s for submodule %r to revision %s"
453+
% (self.path,self.name,hexsha))
453454
ifnotdry_run:
454455
ifis_detached:
455456
# NOTE: for now we force, the user is no supposed to change detached
@@ -638,7 +639,8 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
638639
mod=self.module()
639640
ifmod.is_dirty(untracked_files=True):
640641
raiseInvalidGitRepositoryError(
641-
"Cannot delete module at %s with any modifications, unless force is specified"%mod.working_tree_dir)
642+
"Cannot delete module at %s with any modifications, unless force is specified"
643+
%mod.working_tree_dir)
642644
# END check for dirt
643645

644646
# figure out whether we have new commits compared to the remotes

‎git/objects/submodule/root.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
186186
# in the new remote as well.
187187
iflen([rforrinsmr.refsifr.remote_head==sm.branch_name])==0:
188188
raiseValueError(
189-
"Submodule branch named %r was not available in new submodule remote at %r"% (sm.branch_name,sm.url))
189+
"Submodule branch named %r was not available in new submodule remote at %r"
190+
% (sm.branch_name,sm.url)
191+
)
190192
# END head is not detached
191193

192194
# now delete the changed one
@@ -245,7 +247,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
245247
# this way, it will be checked out in the next step
246248
# This will change the submodule relative to us, so
247249
# the user will be able to commit the change easily
248-
print>>sys.stderr,"WARNING: Current sha %s was not contained in the tracking branch at the new remote, setting it the the remote's tracking branch"%sm.hexsha
250+
print>>sys.stderr,"WARNING: Current sha %s was not contained in the tracking\
251+
branch at the new remote, setting it the the remote's tracking branch"%sm.hexsha
249252
sm.binsha=rref.commit.binsha
250253
# END reset binsha
251254

@@ -262,7 +265,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
262265
# finally, create a new tracking branch which tracks the
263266
# new remote branch
264267
progress.update(BEGIN|BRANCHCHANGE,i,len_csms,prefix+
265-
"Changing branch of submodule %r from %s to %s"% (sm.name,psm.branch_path,sm.branch_path))
268+
"Changing branch of submodule %r from %s to %s"
269+
% (sm.name,psm.branch_path,sm.branch_path))
266270
ifnotdry_run:
267271
smm=sm.module()
268272
smmr=smm.remotes

‎git/objects/tree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ def __div__(self, file):
187187
else:
188188
forinfoinself._cache:
189189
ifinfo[2]==file:# [2] == name
190-
returnself._map_id_to_type[info[1]>>12](self.repo,info[0],info[1],join_path(self.path,info[2]))
190+
returnself._map_id_to_type[info[1]>>12](self.repo,info[0],info[1],
191+
join_path(self.path,info[2]))
191192
# END for each obj
192193
raiseKeyError(msg%file)
193194
# END handle long paths

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp