diff options
Diffstat (limited to 'lib/git/objects')
-rw-r--r-- | lib/git/objects/__init__.py | 2 | ||||
-rw-r--r-- | lib/git/objects/base.py | 4 | ||||
-rw-r--r-- | lib/git/objects/blob.py | 15 | ||||
-rw-r--r-- | lib/git/objects/commit.py | 6 | ||||
-rw-r--r-- | lib/git/objects/tag.py | 2 | ||||
-rw-r--r-- | lib/git/objects/tree.py | 20 | ||||
-rw-r--r-- | lib/git/objects/util.py (renamed from lib/git/objects/utils.py) | 8 |
7 files changed, 25 insertions, 32 deletions
diff --git a/lib/git/objects/__init__.py b/lib/git/objects/__init__.py index 209d8b51..85c7e38c 100644 --- a/lib/git/objects/__init__.py +++ b/lib/git/objects/__init__.py @@ -8,7 +8,7 @@ from blob import * from tree import * from commit import * from submodule import * -from utils import Actor +from util import Actor __all__ = [ name for name, obj in locals().items() if not (name.startswith('_') or inspect.ismodule(obj)) ]
\ No newline at end of file diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py index 97b7898c..d4a46788 100644 --- a/lib/git/objects/base.py +++ b/lib/git/objects/base.py @@ -3,8 +3,8 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from git.utils import LazyMixin, join_path_native, stream_copy -from utils import get_object_type_by_name +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, diff --git a/lib/git/objects/blob.py b/lib/git/objects/blob.py index 8263e9a2..32f8c61c 100644 --- a/lib/git/objects/blob.py +++ b/lib/git/objects/blob.py @@ -14,21 +14,12 @@ class Blob(base.IndexObject): DEFAULT_MIME_TYPE = "text/plain" type = "blob" - __slots__ = "data" - - def _set_cache_(self, attr): - if attr == "data": - ostream = self.repo.odb.stream(self.binsha) - self.size = ostream.size - self.data = ostream.read() - # assert ostream.type == self.type, _assertion_msg_format % (self.binsha, ostream.type, self.type) - else: - super(Blob, self)._set_cache_(attr) - # END handle data + __slots__ = tuple() @property def mime_type(self): - """ :return:String describing the mime type of this file (based on the filename) + """ + :return: String describing the mime type of this file (based on the filename) :note: Defaults to 'text/plain' in case the actual file type is unknown. """ guesses = None if self.path: diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py index f88bb0e8..132d794b 100644 --- a/lib/git/objects/commit.py +++ b/lib/git/objects/commit.py @@ -4,7 +4,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from git.utils import ( +from git.util import ( Iterable, Stats, ) @@ -17,7 +17,7 @@ import base from gitdb.util import ( hex_to_bin ) -from utils import ( +from util import ( Traversable, Serializable, get_user_id, @@ -182,11 +182,11 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): def iter_parents(self, paths='', **kwargs): """Iterate _all_ parents of this commit. + :param paths: Optional path or list of paths limiting the Commits to those that contain at least one of the paths :param kwargs: All arguments allowed by git-rev-list - :return: Iterator yielding Commit objects which are parents of self """ # skip ourselves skip = kwargs.get("skip", 1) diff --git a/lib/git/objects/tag.py b/lib/git/objects/tag.py index 702eae35..ea480fc2 100644 --- a/lib/git/objects/tag.py +++ b/lib/git/objects/tag.py @@ -6,7 +6,7 @@ """ Module containing all object based types. """ import base from gitdb.util import hex_to_bin -from utils import ( +from util import ( get_object_type_by_name, parse_actor_and_date ) diff --git a/lib/git/objects/tree.py b/lib/git/objects/tree.py index 056d3da9..d6e16a31 100644 --- a/lib/git/objects/tree.py +++ b/lib/git/objects/tree.py @@ -3,7 +3,7 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -import utils +import util from base import IndexObject from blob import Blob @@ -23,8 +23,8 @@ from gitdb.util import ( __all__ = ("TreeModifier", "Tree") class TreeModifier(object): - """A utility class providing methods to alter the underlying cache in a list-like - fashion. + """A utility class providing methods to alter the underlying cache in a list-like fashion. + Once all adjustments are complete, the _cache, which really is a refernce to the cache of a tree, will be sorted. Assuring it will be in a serializable state""" __slots__ = '_cache' @@ -57,6 +57,7 @@ class TreeModifier(object): exists, nothing will be done, but a ValueError will be raised if the sha and mode of the existing item do not match the one you add, unless force is True + :param sha: The 20 or 40 byte sha of the item to add :param mode: int representing the stat compatible mode of the item :param force: If True, an item with your name and information will overwrite @@ -100,7 +101,7 @@ class TreeModifier(object): #} END mutators -class Tree(IndexObject, diff.Diffable, utils.Traversable, utils.Serializable): +class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable): """Tree objects represent an ordered list of Blobs and other Trees. ``Tree as a list``:: @@ -203,16 +204,17 @@ class Tree(IndexObject, diff.Diffable, utils.Traversable, utils.Serializable): @property def cache(self): - """:return: An object allowing to modify the internal cache. This can be used - to change the tree's contents. When done, make sure you call ``set_done`` - on the tree modifier, or serialization behaviour will be incorrect. - See the ``TreeModifier`` for more information on how to alter the cache""" + """ + :return: An object allowing to modify the internal cache. This can be used + to change the tree's contents. When done, make sure you call ``set_done`` + on the tree modifier, or serialization behaviour will be incorrect. + See the ``TreeModifier`` for more information on how to alter the cache""" return TreeModifier(self._cache) def traverse( self, predicate = lambda i,d: True, prune = lambda i,d: False, depth = -1, branch_first=True, visit_once = False, ignore_self=1 ): - """For documentation, see utils.Traversable.traverse + """For documentation, see util.Traversable.traverse Trees are set to visit_once = False to gain more performance in the traversal""" return super(Tree, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self) diff --git a/lib/git/objects/utils.py b/lib/git/objects/util.py index c0ddd6e6..fd648f09 100644 --- a/lib/git/objects/utils.py +++ b/lib/git/objects/util.py @@ -103,15 +103,15 @@ def verify_utctz(offset): def parse_date(string_date): """ Parse the given date as one of the following + * Git internal format: timestamp offset * RFC 2822: Thu, 07 Apr 2005 22:13:13 +0200. * ISO 8601 2005-04-07T22:13:13 - The T can be a space as well + The T can be a space as well - :return: Tuple(int(timestamp), int(offset), both in seconds since epoch + :return: Tuple(int(timestamp), int(offset)), both in seconds since epoch :raise ValueError: If the format could not be understood - :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY - """ + :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY""" # git time try: if string_date.count(' ') == 1 and string_date.rfind(':') == -1: |