Skip to content

Commit c80d727

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 parent 965a08c commit c80d727

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
if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != 'full' or as_process):
337-
print ' '.join(command)
337+
print(' '.join(command))
338338

339339
# Allow the user to have the command executed in their working dir.
340340
if with_keep_cwd or self._working_dir is None:
@@ -389,11 +389,11 @@ def execute(self, command,
389389
if self.GIT_PYTHON_TRACE == 'full':
390390
cmdstr = " ".join(command)
391391
if stderr_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
elif stdout_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
if with_exceptions and status != 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
return self.execute(make_call(), **_kwargs)
529528
finally:
530529
import warnings
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
import re
10-
import os
1110
import ConfigParser as cp
1211
import inspect
13-
import cStringIO
1412

1513
from git.odict import OrderedDict
1614
from git.util import LockFile
@@ -188,8 +186,8 @@ def __del__(self):
188186
try:
189187
try:
190188
self.write()
191-
except IOError, e:
192-
print "Exception during destruction of GitConfigParser: %s" % str(e)
189+
except IOError as e:
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-
except IOError, e:
288+
except IOError:
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
import re
88
from objects.blob import Blob
99
from objects.util import mode_str_to_int
10-
from exc import GitCommandError
1110

1211
from gitdb.util import hex_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
return index
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 100644 6870991011cc8d9853a7a8a6f02061512c6a8190 37c5e30c879213e9ae83b21e9d11e55fc20c54b7 M .gitignore
323+
# :100644 100644 687099101... 37c5e30c8... M .gitignore
325324
index = DiffIndex()
326325
for line in stream:
327326
if not line.startswith(":"):

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-
from base import *
4-
from typ import *
3+
from __future__ import absolute_import
4+
5+
from .base import *
6+
from .typ import *

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-
import git.objects
2827
import git.diff as diff
2928

3029
from git.exc import (
@@ -43,13 +42,11 @@
4342
from git.objects.util import Serializable
4443

4544
from git.util import (
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
from fun import (
@@ -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
for entry in self.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
def add(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-
return Commit.create_from_tree(self.repo, tree, message, parent_commits, head, author=author, committer=committer)
889+
return Commit.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
if failed_files:
996991
valid_files = list(set(iter_checked_out_files) - set(failed_files))
997992
raise CheckoutError(
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
if paths is None:

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-
assert len(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+
assert len(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] and base[0] != theirs[0] and ours[0] != theirs[0] ) or \
267+
if(base[0] != ours[0] and base[0] != theirs[0] and ours[0] != theirs[0]) or \
269268
(base[1] != ours[1] and base[1] != theirs[1] and ours[1] != theirs[1]):
270269
# changed by both
271270
out_append(_tree_entry_to_baseindexentry(base, 1))

0 commit comments

Comments
 (0)