예제 #1
0
파일: repo.py 프로젝트: riverfor/dulwich
def parse_graftpoints(graftpoints):
    """Convert a list of graftpoints into a dict

    :param graftpoints: Iterator of graftpoint lines

    Each line is formatted as:
        <commit sha1> <parent sha1> [<parent sha1>]*

    Resulting dictionary is:
        <commit sha1>: [<parent sha1>*]

    https://git.wiki.kernel.org/index.php/GraftPoint
    """
    grafts = {}
    for l in graftpoints:
        raw_graft = l.split(None, 1)

        commit = raw_graft[0]
        if len(raw_graft) == 2:
            parents = raw_graft[1].split()
        else:
            parents = []

        for sha in [commit] + parents:
            check_hexsha(sha, 'Invalid graftpoint')

        grafts[commit] = parents
    return grafts
예제 #2
0
def parse_graftpoints(graftpoints):
    """Convert a list of graftpoints into a dict

    :param graftpoints: Iterator of graftpoint lines

    Each line is formatted as:
        <commit sha1> <parent sha1> [<parent sha1>]*

    Resulting dictionary is:
        <commit sha1>: [<parent sha1>*]

    https://git.wiki.kernel.org/index.php/GraftPoint
    """
    grafts = {}
    for l in graftpoints:
        raw_graft = l.split(None, 1)

        commit = raw_graft[0]
        if len(raw_graft) == 2:
            parents = raw_graft[1].split()
        else:
            parents = []

        for sha in [commit] + parents:
            check_hexsha(sha, 'Invalid graftpoint')

        grafts[commit] = parents
    return grafts
예제 #3
0
 def test_check_hexsha(self):
     check_hexsha(a_sha, "failed to check good sha")
     self.assertRaises(ObjectFormatException, check_hexsha, '1' * 39,
                       'sha too short')
     self.assertRaises(ObjectFormatException, check_hexsha, '1' * 41,
                       'sha too long')
     self.assertRaises(ObjectFormatException, check_hexsha, 'x' * 40,
                       'invalid characters')
예제 #4
0
 def test_check_hexsha(self):
     check_hexsha(a_sha, "failed to check good sha")
     self.assertRaises(ObjectFormatException, check_hexsha, '1' * 39,
                       'sha too short')
     self.assertRaises(ObjectFormatException, check_hexsha, '1' * 41,
                       'sha too long')
     self.assertRaises(ObjectFormatException, check_hexsha, 'x' * 40,
                       'invalid characters')
예제 #5
0
파일: repo.py 프로젝트: riverfor/dulwich
    def _add_graftpoints(self, updated_graftpoints):
        """Add or modify graftpoints

        :param updated_graftpoints: Dict of commit shas to list of parent shas
        """

        # Simple validation
        for commit, parents in updated_graftpoints.items():
            for sha in [commit] + parents:
                check_hexsha(sha, 'Invalid graftpoint')

        self._graftpoints.update(updated_graftpoints)
예제 #6
0
    def _add_graftpoints(self, updated_graftpoints):
        """Add or modify graftpoints

        :param updated_graftpoints: Dict of commit shas to list of parent shas
        """

        # Simple validation
        for commit, parents in updated_graftpoints.items():
            for sha in [commit] + parents:
                check_hexsha(sha, 'Invalid graftpoint')

        self._graftpoints.update(updated_graftpoints)
예제 #7
0
 def test_check_hexsha(self):
     check_hexsha(a_sha, "failed to check good sha")
     self.assertRaises(ObjectFormatException, check_hexsha, "1" * 39, "sha too short")
     self.assertRaises(ObjectFormatException, check_hexsha, "1" * 41, "sha too long")
     self.assertRaises(ObjectFormatException, check_hexsha, "x" * 40, "invalid characters")