Example #1
0
 def new_from_sha(cls, repo, sha1):
     """
     :return: new object instance of a type appropriate to represent the given
         binary sha1
     :param sha1: 20 byte binary sha1"""
     if sha1 == cls.NULL_BIN_SHA:
         # the NULL binsha is always the root commit
         return get_object_type_by_name('commit')(repo, sha1)
         # END handle special case
     oinfo = repo.odb.info(sha1)
     inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha)
     inst.size = oinfo.size
     return inst
Example #2
0
 def new_from_sha(cls, repo, sha1):
     """
     :return: new object instance of a type appropriate to represent the given
         binary sha1
     :param sha1: 20 byte binary sha1"""
     if sha1 == cls.NULL_BIN_SHA:
         # the NULL binsha is always the root commit
         return get_object_type_by_name('commit')(repo, sha1)
     #END handle special case
     oinfo = repo.odb.info(sha1)
     inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha)
     inst.size = oinfo.size
     return inst
Example #3
0
    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 <hexsha>
            type_token, type_name = lines[1].split(" ")  # type <type_name>
            self.object = get_object_type_by_name(type_name)(
                self.repo, hex_to_bin(hexsha))

            self.tag = lines[2][4:]  # tag <tag name>

            tagger_info = lines[3][7:]  # tagger <actor> <date>
            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)
Example #4
0
	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 <hexsha>
			type_token, type_name = lines[1].split(" ") # type <type_name>
			self.object = get_object_type_by_name(type_name)(self.odb, hex_to_bin(hexsha))
			
			self.tag = lines[2][4:]	 # tag <tag name>
			
			tagger_info = lines[3][7:]# tagger <actor> <date>
			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)
    def new_from_sha(cls, repo, sha1):
        """
		:return: new object instance of a type appropriate to represent the given 
			binary sha1
		:param sha1: 20 byte binary sha1"""
        oinfo = repo.odb.info(sha1)
        inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha)
        inst.size = oinfo.size
        return inst
Example #6
0
	def new_from_sha(cls, repo, sha1):
		"""
		:return: new object instance of a type appropriate to represent the given 
			binary sha1
		:param sha1: 20 byte binary sha1"""
		oinfo = repo.odb.info(sha1)
		inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha)
		inst.size = oinfo.size
		return inst