diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-04 13:48:29 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-04 13:48:29 +0100 |
commit | c80d727e374321573bb00e23876a67c77ff466e3 (patch) | |
tree | 7590d6ae544eac56e83639d27e1f9013b38d8a4b /git/objects | |
parent | 965a08c3f9f2fbd62691d533425c699c943cb865 (diff) | |
download | gitpython-c80d727e374321573bb00e23876a67c77ff466e3.tar.gz |
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
Diffstat (limited to 'git/objects')
-rw-r--r-- | git/objects/__init__.py | 21 | ||||
-rw-r--r-- | git/objects/base.py | 1 | ||||
-rw-r--r-- | git/objects/commit.py | 4 | ||||
-rw-r--r-- | git/objects/submodule/base.py | 12 | ||||
-rw-r--r-- | git/objects/submodule/root.py | 10 | ||||
-rw-r--r-- | git/objects/tree.py | 3 | ||||
-rw-r--r-- | git/objects/util.py | 9 |
7 files changed, 33 insertions, 27 deletions
diff --git a/git/objects/__init__.py b/git/objects/__init__.py index 0b40934c..1fe881f3 100644 --- a/git/objects/__init__.py +++ b/git/objects/__init__.py @@ -1,21 +1,22 @@ """ Import all submodules main classes into the package space """ +from __future__ import absolute_import import inspect -from base import * +from .base import * # Fix import dependency - add IndexObject to the util module, so that it can be # imported by the submodule.base -import submodule.util -submodule.util.IndexObject = IndexObject -submodule.util.Object = Object -from submodule.base import * -from submodule.root import * +from .submodule import util +util.IndexObject = IndexObject +util.Object = Object +from .submodule.base import * +from .submodule.root import * # must come after submodule was made available -from tag import * -from blob import * -from commit import * -from tree import * +from .tag import * +from .blob import * +from .commit import * +from .tree import * __all__ = [name for name, obj in locals().items() if not (name.startswith('_') or inspect.ismodule(obj))] diff --git a/git/objects/base.py b/git/objects/base.py index 50647a3a..20147e57 100644 --- a/git/objects/base.py +++ b/git/objects/base.py @@ -6,7 +6,6 @@ from git.util import LazyMixin, join_path_native, stream_copy from util import get_object_type_by_name from gitdb.util import ( - hex_to_bin, bin_to_hex, basename ) diff --git a/git/objects/commit.py b/git/objects/commit.py index c6adcc94..4a4a314c 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -276,9 +276,9 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): If True, the HEAD will be advanced to the new commit automatically. Else the HEAD will remain pointing on the previous commit. This could lead to undesired results when diffing files. - :param author: The name of the author, optional. If unset, the repository + :param author: The name of the author, optional. If unset, the repository configuration is used to obtain this value. - :param committer: The name of the committer, optional. If unset, the + :param committer: The name of the committer, optional. If unset, the repository configuration is used to obtain this value. :return: Commit object representing the new commit diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index e3d58077..6951fd63 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -28,7 +28,6 @@ import git import os import sys -import time __all__ = ["Submodule", "UpdateProgress"] @@ -140,7 +139,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): return self._name def __repr__(self): - return "git.%s(name=%s, path=%s, url=%s, branch_path=%s)" % (type(self).__name__, self._name, self.path, self.url, self.branch_path) + return "git.%s(name=%s, path=%s, url=%s, branch_path=%s)"\ + % (type(self).__name__, self._name, self.path, self.url, self.branch_path) @classmethod def _config_parser(cls, repo, parent_commit, read_only): @@ -236,7 +236,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): # assure we never put backslashes into the url, as some operating systems # like it ... - if url != None: + if url is not None: url = to_native_path_linux(url) # END assure url correctness @@ -449,7 +449,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): # handles dry_run if mrepo is not None and mrepo.head.commit.binsha != binsha: progress.update(BEGIN | UPDWKTREE, 0, 1, prefix + - "Updating working tree at %s for submodule %r to revision %s" % (self.path, self.name, hexsha)) + "Updating working tree at %s for submodule %r to revision %s" + % (self.path, self.name, hexsha)) if not dry_run: if is_detached: # NOTE: for now we force, the user is no supposed to change detached @@ -638,7 +639,8 @@ class Submodule(util.IndexObject, Iterable, Traversable): mod = self.module() if mod.is_dirty(untracked_files=True): raise InvalidGitRepositoryError( - "Cannot delete module at %s with any modifications, unless force is specified" % mod.working_tree_dir) + "Cannot delete module at %s with any modifications, unless force is specified" + % mod.working_tree_dir) # END check for dirt # figure out whether we have new commits compared to the remotes diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index f68f7567..871cc21c 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -186,7 +186,9 @@ class RootModule(Submodule): # in the new remote as well. if len([r for r in smr.refs if r.remote_head == sm.branch_name]) == 0: raise ValueError( - "Submodule branch named %r was not available in new submodule remote at %r" % (sm.branch_name, sm.url)) + "Submodule branch named %r was not available in new submodule remote at %r" + % (sm.branch_name, sm.url) + ) # END head is not detached # now delete the changed one @@ -245,7 +247,8 @@ class RootModule(Submodule): # this way, it will be checked out in the next step # This will change the submodule relative to us, so # the user will be able to commit the change easily - 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 + 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 sm.binsha = rref.commit.binsha # END reset binsha @@ -262,7 +265,8 @@ class RootModule(Submodule): # finally, create a new tracking branch which tracks the # new remote branch progress.update(BEGIN | BRANCHCHANGE, i, len_csms, prefix + - "Changing branch of submodule %r from %s to %s" % (sm.name, psm.branch_path, sm.branch_path)) + "Changing branch of submodule %r from %s to %s" + % (sm.name, psm.branch_path, sm.branch_path)) if not dry_run: smm = sm.module() smmr = smm.remotes diff --git a/git/objects/tree.py b/git/objects/tree.py index 9f63e4e3..beb5f1fd 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -187,7 +187,8 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): else: for info in self._cache: if info[2] == file: # [2] == name - return self._map_id_to_type[info[1] >> 12](self.repo, info[0], info[1], join_path(self.path, info[2])) + return self._map_id_to_type[info[1] >> 12](self.repo, info[0], info[1], + join_path(self.path, info[2])) # END for each obj raise KeyError(msg % file) # END handle long paths diff --git a/git/objects/util.py b/git/objects/util.py index 76a24a6f..fdf9622b 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -15,7 +15,6 @@ from collections import deque as Deque from string import digits import time import calendar -import os __all__ = ('get_object_type_by_name', 'parse_date', 'parse_actor_and_date', 'ProcessStreamAdapter', 'Traversable', 'altz_to_utctz_str', 'utctz_to_altz', @@ -89,10 +88,10 @@ def verify_utctz(offset): raise fmt_exc if offset[0] not in "+-": raise fmt_exc - if offset[1] not in digits or \ - offset[2] not in digits or \ - offset[3] not in digits or \ - offset[4] not in digits: + if offset[1] not in digits or\ + offset[2] not in digits or\ + offset[3] not in digits or\ + offset[4] not in digits: raise fmt_exc # END for each char return offset |