summaryrefslogtreecommitdiff
path: root/lib/git/objects/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git/objects/base.py')
-rw-r--r--lib/git/objects/base.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py
index 41862ac2..b8cec47f 100644
--- a/lib/git/objects/base.py
+++ b/lib/git/objects/base.py
@@ -62,17 +62,6 @@ class Object(LazyMixin):
inst.size = oinfo.size
return inst
- def _set_self_from_args_(self, args_dict):
- """Initialize attributes on self from the given dict that was retrieved
- from locals() in the calling method.
-
- Will only set an attribute on self if the corresponding value in args_dict
- is not None"""
- for attr, val in args_dict.items():
- if attr != "self" and val is not None:
- setattr( self, attr, val )
- # END set all non-None attributes
-
def _set_cache_(self, attr):
"""Retrieve object information"""
if attr == "size":
@@ -125,7 +114,10 @@ class Object(LazyMixin):
class IndexObject(Object):
"""Base for all objects that can be part of the index file , namely Tree, Blob and
SubModule objects"""
- __slots__ = ("path", "mode")
+ __slots__ = ("path", "mode")
+
+ # for compatability with iterable lists
+ _id_attribute_ = 'path'
def __init__(self, repo, binsha, mode=None, path=None):
"""Initialize a newly instanced IndexObject
@@ -140,7 +132,10 @@ class IndexObject(Object):
Path may not be set of the index object has been created directly as it cannot
be retrieved without knowing the parent tree."""
super(IndexObject, self).__init__(repo, binsha)
- self._set_self_from_args_(locals())
+ if mode is not None:
+ self.mode = mode
+ if path is not None:
+ self.path = path
def __hash__(self):
""":return: