Пример #1
0
 def _read_from_file(self):
     fmap = file_contents_ro_filepath(self._path,
                                      stream=False,
                                      allow_mmap=True)
     try:
         self._deserialize(fmap)
     finally:
         fmap.close()
Пример #2
0
 def _map_loose_object(self, sha):
     """
     :return: memory map of that file to allow random read access
     :raise BadObject: if object could not be located"""
     db_path = self.db_path(self.object_path(bin_to_hex(sha)))
     try:
         return file_contents_ro_filepath(db_path, flags=self._fd_open_flags)
     except OSError as e:
         if e.errno != ENOENT:
             # try again without noatime
             try:
                 return file_contents_ro_filepath(db_path)
             except OSError:
                 raise BadObject(sha)
             # didn't work because of our flag, don't try it again
             self._fd_open_flags = 0
         else:
             raise BadObject(sha)
Пример #3
0
 def _map_loose_object(self, sha):
     """
     :return: memory map of that file to allow random read access
     :raise BadObject: if object could not be located"""
     db_path = self.db_path(self.object_path(bin_to_hex(sha)))
     try:
         return file_contents_ro_filepath(db_path, flags=self._fd_open_flags)
     except OSError as e:
         if e.errno != ENOENT:
             # try again without noatime
             try:
                 return file_contents_ro_filepath(db_path)
             except OSError:
                 raise BadObject(sha)
             # didn't work because of our flag, don't try it again
             self._fd_open_flags = 0
         else:
             raise BadObject(sha)
Пример #4
0
    def _read_from_file(self):
        try:
            fmap = file_contents_ro_filepath(self._path, stream=True, allow_mmap=True)
        except OSError:
            # it is possible and allowed that the file doesn't exist !
            return
        # END handle invalid log

        try:
            self._deserialize(fmap)
        finally:
            fmap.close()
Пример #5
0
    def _read_from_file(self):
        try:
            fmap = file_contents_ro_filepath(self._path,
                                             stream=True,
                                             allow_mmap=True)
        except OSError:
            # it is possible and allowed that the file doesn't exist !
            return
        #END handle invalid log

        try:
            self._deserialize(fmap)
        finally:
            fmap.close()
Пример #6
0
 def iter_entries(cls, stream):
     """
     :return: Iterator yielding RefLogEntry instances, one for each line read
         sfrom the given stream.
     :param stream: file-like object containing the revlog in its native format
         or basestring instance pointing to a file to read"""
     new_entry = RefLogEntry.from_line
     if isinstance(stream, basestring):
         stream = file_contents_ro_filepath(stream)
     #END handle stream type
     while True:
         line = stream.readline()
         if not line:
             return
         yield new_entry(line.strip())
Пример #7
0
    def iter_entries(cls, stream):
        """
		:return: Iterator yielding RefLogEntry instances, one for each line read 
			sfrom the given stream.
		:param stream: file-like object containing the revlog in its native format
			or basestring instance pointing to a file to read"""
        new_entry = RefLogEntry.from_line
        if isinstance(stream, basestring):
            stream = file_contents_ro_filepath(stream)
            # END handle stream type
        while True:
            line = stream.readline()
            if not line:
                return
            yield new_entry(line.strip())
Пример #8
0
 def _read_from_file(self):
     fmap = file_contents_ro_filepath(self._path, stream=False, allow_mmap=True)
     try:
         self._deserialize(fmap)
     finally:
         fmap.close()