예제 #1
0
    def check(self):
        """Check this object for internal consistency.

        Raises:
          ObjectFormatException: if the object is malformed in some way
        """
        super(Tree, self).check()
        last = None
        allowed_modes = (
            stat.S_IFREG | 0o755,
            stat.S_IFREG | 0o644,
            stat.S_IFLNK,
            stat.S_IFDIR,
            S_IFGITLINK,
            # TODO: optionally exclude as in git fsck --strict
            stat.S_IFREG | 0o664,
        )
        for name, mode, sha in parse_tree(b"".join(self._chunked_text), True):
            check_hexsha(sha, "invalid sha %s" % sha)
            if b"/" in name or name in (b"", b".", b"..", b".git"):
                raise ObjectFormatException("invalid name %s" %
                                            name.decode("utf-8", "replace"))

            if mode not in allowed_modes:
                raise ObjectFormatException("invalid mode %06o" % mode)

            entry = (name, (mode, sha))
            if last:
                if key_entry(last) > key_entry(entry):
                    raise ObjectFormatException("entries not sorted")
                if name == last[0]:
                    raise ObjectFormatException("duplicate entry %s" % name)
            last = entry
예제 #2
0
    def check(self):
        """Check this object for internal consistency.

        :raise ObjectFormatException: if the object is malformed in some way
        """
        super(Tree, self).check()
        last = None
        allowed_modes = (stat.S_IFREG | 0755, stat.S_IFREG | 0644,
                         stat.S_IFLNK, stat.S_IFDIR, S_IFGITLINK,
                         # TODO: optionally exclude as in git fsck --strict
                         stat.S_IFREG | 0664)
        for name, mode, sha in parse_tree(''.join(self._chunked_text),
                                          True):
            check_hexsha(sha, 'invalid sha %s' % sha)
            if '/' in name or name in ('', '.', '..'):
                raise ObjectFormatException('invalid name %s' % name)

            if mode not in allowed_modes:
                raise ObjectFormatException('invalid mode %06o' % mode)

            entry = (name, (mode, sha))
            if last:
                if cmp_entry(last, entry) > 0:
                    raise ObjectFormatException('entries not sorted')
                if name == last[0]:
                    raise ObjectFormatException('duplicate entry %s' % name)
            last = entry
예제 #3
0
    def check(self):
        """Check this object for internal consistency.

        :raise ObjectFormatException: if the object is malformed in some way
        """
        super(Tree, self).check()
        last = None
        allowed_modes = (
            stat.S_IFREG | 0755,
            stat.S_IFREG | 0644,
            stat.S_IFLNK,
            stat.S_IFDIR,
            S_IFGITLINK,
            # TODO: optionally exclude as in git fsck --strict
            stat.S_IFREG | 0664)
        for name, mode, sha in parse_tree(''.join(self._chunked_text), True):
            check_hexsha(sha, 'invalid sha %s' % sha)
            if '/' in name or name in ('', '.', '..'):
                raise ObjectFormatException('invalid name %s' % name)

            if mode not in allowed_modes:
                raise ObjectFormatException('invalid mode %06o' % mode)

            entry = (name, (mode, sha))
            if last:
                if cmp_entry(last, entry) > 0:
                    raise ObjectFormatException('entries not sorted')
                if name == last[0]:
                    raise ObjectFormatException('duplicate entry %s' % name)
            last = entry
예제 #4
0
파일: objects.py 프로젝트: ardumont/dulwich
    def check(self):
        """Check this object for internal consistency.

        :raise ObjectFormatException: if the object is malformed in some way
        """
        super(Tree, self).check()
        last = None
        allowed_modes = (
            stat.S_IFREG | 0o755,
            stat.S_IFREG | 0o644,
            stat.S_IFLNK,
            stat.S_IFDIR,
            S_IFGITLINK,
            # TODO: optionally exclude as in git fsck --strict
            stat.S_IFREG | 0o664,
        )
        for name, mode, sha in parse_tree(b"".join(self._chunked_text), True):
            check_hexsha(sha, "invalid sha %s" % sha)
            if b"/" in name or name in (b"", b".", b".."):
                raise ObjectFormatException("invalid name %s" % name)

            if mode not in allowed_modes:
                raise ObjectFormatException("invalid mode %06o" % mode)

            entry = (name, (mode, sha))
            if last:
                if key_entry(last) > key_entry(entry):
                    raise ObjectFormatException("entries not sorted")
                if name == last[0]:
                    raise ObjectFormatException("duplicate entry %s" % name)
            last = entry
예제 #5
0
 def _deserialize(self, chunks):
     """Grab the entries in the tree"""
     try:
         parsed_entries = parse_tree(b''.join(chunks))
     except ValueError as e:
         raise ObjectFormatException(e)
     # TODO: list comprehension is for efficiency in the common (small)
     # case; if memory efficiency in the large case is a concern, use a genexp.
     self._entries = dict([(n, (m, s)) for n, m, s in parsed_entries])
예제 #6
0
 def _deserialize(self, chunks):
     """Grab the entries in the tree"""
     try:
         parsed_entries = parse_tree(b''.join(chunks))
     except ValueError as e:
         raise ObjectFormatException(e)
     # TODO: list comprehension is for efficiency in the common (small)
     # case; if memory efficiency in the large case is a concern, use a genexp.
     self._entries = dict([(n, (m, s)) for n, m, s in parsed_entries])
예제 #7
0
 def _deserialize(self, chunks):
     """Grab the entries in the tree"""
     try:
         parsed_entries = parse_tree("".join(chunks))
     except ValueError, e:
         raise ObjectFormatException(e)
예제 #8
0
 def _deserialize(self, chunks):
     """Grab the entries in the tree"""
     try:
         parsed_entries = parse_tree("".join(chunks))
     except ValueError, e:
         raise ObjectFormatException(e)
예제 #9
0
파일: objects.py 프로젝트: brosner/dulwich
 def _parse_text(self):
     """Grab the entries in the tree"""
     self._entries = parse_tree(self._text)
     self._needs_parsing = False