From a12a7618a1f6f61a4c97ddf4cc422158c3fa72ba Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Apr 2011 20:17:00 +0200 Subject: Updated objects to use the ones defined in gitdb as basis. Only the submodule implementation is left in git-python as it requires some advanced features. No tests where run yet --- git/objects/tag.py | 71 +++--------------------------------------------------- 1 file changed, 4 insertions(+), 67 deletions(-) (limited to 'git/objects/tag.py') diff --git a/git/objects/tag.py b/git/objects/tag.py index c7d02abe..a3a85eef 100644 --- a/git/objects/tag.py +++ b/git/objects/tag.py @@ -4,73 +4,10 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php """ Module containing all object based types. """ -import base -from gitdb.util import hex_to_bin -from util import ( - get_object_type_by_name, - parse_actor_and_date - ) - +from git.util import RepoAliasMixin +from gitdb.object.tag import GitDB_TagObject __all__ = ("TagObject", ) -class TagObject(base.Object): +class TagObject(GitDB_TagObject, RepoAliasMixin): """Non-Lightweight tag carrying additional information about an object we are pointing to.""" - type = "tag" - __slots__ = ( "object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message" ) - - def __init__(self, repo, binsha, object=None, tag=None, - tagger=None, tagged_date=None, tagger_tz_offset=None, message=None): - """Initialize a tag object with additional data - - :param repo: repository this object is located in - :param binsha: 20 byte SHA1 - :param object: Object instance of object we are pointing to - :param tag: name of this tag - :param tagger: Actor identifying the tagger - :param tagged_date: int_seconds_since_epoch - is the DateTime of the tag creation - use time.gmtime to convert - it into a different format - :param tagged_tz_offset: int_seconds_west_of_utc is the timezone that the - authored_date is in, in a format similar to time.altzone""" - super(TagObject, self).__init__(repo, binsha ) - if object is not None: - self.object = object - if tag is not None: - self.tag = tag - if tagger is not None: - self.tagger = tagger - if tagged_date is not None: - self.tagged_date = tagged_date - if tagger_tz_offset is not None: - self.tagger_tz_offset = tagger_tz_offset - if message is not None: - self.message = message - - def _set_cache_(self, attr): - """Cache all our attributes at once""" - if attr in TagObject.__slots__: - ostream = self.repo.odb.stream(self.binsha) - lines = ostream.read().splitlines() - - obj, hexsha = lines[0].split(" ") # object - type_token, type_name = lines[1].split(" ") # type - self.object = get_object_type_by_name(type_name)(self.repo, hex_to_bin(hexsha)) - - self.tag = lines[2][4:] # tag - - tagger_info = lines[3][7:]# tagger - self.tagger, self.tagged_date, self.tagger_tz_offset = parse_actor_and_date(tagger_info) - - # line 4 empty - it could mark the beginning of the next header - # in case there really is no message, it would not exist. Otherwise - # a newline separates header from message - if len(lines) > 5: - self.message = "\n".join(lines[5:]) - else: - self.message = '' - # END check our attributes - else: - super(TagObject, self)._set_cache_(attr) - - - + __slots__ = tuple() -- cgit v1.2.3 From 9fc7b9a068189cc0d249d0870dfb0112ab5dec92 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 May 2011 15:25:11 +0200 Subject: Made most primal imports work, but stopped here as there are many more changes when doing the merge --- git/objects/tag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/objects/tag.py') diff --git a/git/objects/tag.py b/git/objects/tag.py index a3a85eef..59b2362e 100644 --- a/git/objects/tag.py +++ b/git/objects/tag.py @@ -5,7 +5,7 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php """ Module containing all object based types. """ from git.util import RepoAliasMixin -from gitdb.object.tag import GitDB_TagObject +from gitdb.object.tag import TagObject as GitDB_TagObject __all__ = ("TagObject", ) class TagObject(GitDB_TagObject, RepoAliasMixin): -- cgit v1.2.3 From 4177eefd7bdaea96a529b00ba9cf751924ede202 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 May 2011 19:43:22 +0200 Subject: Added all code from gitdb to gitpython. Next is to make it generally work. Then the tests will need some work --- git/objects/tag.py | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 3 deletions(-) (limited to 'git/objects/tag.py') diff --git a/git/objects/tag.py b/git/objects/tag.py index 59b2362e..0bd1d20c 100644 --- a/git/objects/tag.py +++ b/git/objects/tag.py @@ -4,10 +4,77 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php """ Module containing all object based types. """ +import base from git.util import RepoAliasMixin -from gitdb.object.tag import TagObject as GitDB_TagObject +from gitdb.util import hex_to_bin +from util import ( + get_object_type_by_name, + parse_actor_and_date + ) +from gitdb.typ import ObjectType + __all__ = ("TagObject", ) -class TagObject(GitDB_TagObject, RepoAliasMixin): +class TagObject(base.Object, RepoAliasMixin): """Non-Lightweight tag carrying additional information about an object we are pointing to.""" - __slots__ = tuple() + type = ObjectType.tag + type_id = ObjectType.tag_id + + __slots__ = ( "object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message" ) + + def __init__(self, odb, binsha, object=None, tag=None, + tagger=None, tagged_date=None, tagger_tz_offset=None, message=None): + """Initialize a tag object with additional data + + :param odb: repository this object is located in + :param binsha: 20 byte SHA1 + :param object: Object instance of object we are pointing to + :param tag: name of this tag + :param tagger: Actor identifying the tagger + :param tagged_date: int_seconds_since_epoch + is the DateTime of the tag creation - use time.gmtime to convert + it into a different format + :param tagged_tz_offset: int_seconds_west_of_utc is the timezone that the + authored_date is in, in a format similar to time.altzone""" + super(TagObject, self).__init__(odb, binsha ) + if object is not None: + self.object = object + if tag is not None: + self.tag = tag + if tagger is not None: + self.tagger = tagger + if tagged_date is not None: + self.tagged_date = tagged_date + if tagger_tz_offset is not None: + self.tagger_tz_offset = tagger_tz_offset + if message is not None: + self.message = message + + def _set_cache_(self, attr): + """Cache all our attributes at once""" + if attr in TagObject.__slots__: + ostream = self.odb.stream(self.binsha) + lines = ostream.read().splitlines() + + obj, hexsha = lines[0].split(" ") # object + type_token, type_name = lines[1].split(" ") # type + self.object = get_object_type_by_name(type_name)(self.odb, hex_to_bin(hexsha)) + + self.tag = lines[2][4:] # tag + + tagger_info = lines[3][7:]# tagger + self.tagger, self.tagged_date, self.tagger_tz_offset = parse_actor_and_date(tagger_info) + + # line 4 empty - it could mark the beginning of the next header + # in case there really is no message, it would not exist. Otherwise + # a newline separates header from message + if len(lines) > 5: + self.message = "\n".join(lines[5:]) + else: + self.message = '' + # END check our attributes + else: + super(TagObject, self)._set_cache_(attr) + + + -- cgit v1.2.3 From acf5e6ea64a2f24117f1d419c208ed1c38c43690 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 6 May 2011 15:03:14 +0200 Subject: replaced all gitdb strings with git --- git/objects/tag.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/objects/tag.py') diff --git a/git/objects/tag.py b/git/objects/tag.py index 0bd1d20c..5dcd9bf9 100644 --- a/git/objects/tag.py +++ b/git/objects/tag.py @@ -6,12 +6,12 @@ """ Module containing all object based types. """ import base from git.util import RepoAliasMixin -from gitdb.util import hex_to_bin +from git.util import hex_to_bin from util import ( get_object_type_by_name, parse_actor_and_date ) -from gitdb.typ import ObjectType +from git.typ import ObjectType __all__ = ("TagObject", ) -- cgit v1.2.3