Example #1
0
 def test_pypy_issue(self):
     # Test for https://github.com/jelmer/dulwich/issues/509 /
     # https://bitbucket.org/pypy/pypy/issues/2499/cpyext-pystring_asstring-doesnt-work
     chunks = [
         b'tree 03207ccf58880a748188836155ceed72f03d65d6\n'
         b'parent 408fbab530fd4abe49249a636a10f10f44d07a21\n'
         b'author Victor Stinner <*****@*****.**> 1421355207 +0100\n'
         b'committer Victor Stinner <*****@*****.**> 1421355207 +0100\n'
         b'\n'
         b'Backout changeset 3a06020af8cf\n'
         b'\nStreamWriter: close() now clears the reference to the transport\n'
         b'\nStreamWriter now raises an exception if it is closed: write(), writelines(),\n'
         b'write_eof(), can_write_eof(), get_extra_info(), drain().\n']
     delta = [
         b'\xcd\x03\xad\x03]tree ff3c181a393d5a7270cddc01ea863818a8621ca8\n'
         b'parent 20a103cc90135494162e819f98d0edfc1f1fba6b\x91]7\x0510738'
         b'\x91\x99@\x0b10738 +0100\x93\x04\x01\xc9']
     res = apply_delta(chunks, delta)
     expected = [
         b'tree ff3c181a393d5a7270cddc01ea863818a8621ca8\n'
         b'parent 20a103cc90135494162e819f98d0edfc1f1fba6b',
         b'\nauthor Victor Stinner <*****@*****.**> 14213',
         b'10738',
         b' +0100\ncommitter Victor Stinner <*****@*****.**> 14213',
         b'10738 +0100',
         b'\n\nStreamWriter: close() now clears the reference to the transport\n\n'
         b'StreamWriter now raises an exception if it is closed: write(), writelines(),\n'
         b'write_eof(), can_write_eof(), get_extra_info(), drain().\n']
     self.assertEqual(b''.join(expected), b''.join(res))
Example #2
0
    def get_git_author(self, ctx):
        # hg authors might not have emails
        author = ctx.user()

        # see if a translation exists
        if author in self.author_map:
            author = self.author_map[author]

        # check for git author pattern compliance
        regex = re.compile('^(.*?) ?\<(.*?)(?:\>(.*))?$')
        a = regex.match(author)

        if a:
            name = self.get_valid_git_username_email(a.group(1))
            email = self.get_valid_git_username_email(a.group(2))
            if a.group(3) != None and len(a.group(3)) != 0:
                name += ' ext:(' + urllib.quote(a.group(3)) + ')'
            author = self.get_valid_git_username_email(name) + ' <' + self.get_valid_git_username_email(email) + '>'
        elif '@' in author:
            author = self.get_valid_git_username_email(author) + ' <' + self.get_valid_git_username_email(author) + '>'
        else:
            author = self.get_valid_git_username_email(author) + ' <none@none>'

        if 'author' in ctx.extra():
            author = "".join(apply_delta(author, ctx.extra()['author']))

        return author
Example #3
0
 def test_pypy_issue(self):
     # Test for https://github.com/jelmer/dulwich/issues/509 /
     # https://bitbucket.org/pypy/pypy/issues/2499/cpyext-pystring_asstring-doesnt-work
     chunks = [
         b'tree 03207ccf58880a748188836155ceed72f03d65d6\n'
         b'parent 408fbab530fd4abe49249a636a10f10f44d07a21\n'
         b'author Victor Stinner <*****@*****.**> 1421355207 +0100\n'
         b'committer Victor Stinner <*****@*****.**> 1421355207 +0100\n'
         b'\n'
         b'Backout changeset 3a06020af8cf\n'
         b'\nStreamWriter: close() now clears the reference to the transport\n'
         b'\nStreamWriter now raises an exception if it is closed: write(), writelines(),\n'
         b'write_eof(), can_write_eof(), get_extra_info(), drain().\n'
     ]
     delta = [
         b'\xcd\x03\xad\x03]tree ff3c181a393d5a7270cddc01ea863818a8621ca8\n'
         b'parent 20a103cc90135494162e819f98d0edfc1f1fba6b\x91]7\x0510738'
         b'\x91\x99@\x0b10738 +0100\x93\x04\x01\xc9'
     ]
     res = apply_delta(chunks, delta)
     expected = [
         b'tree ff3c181a393d5a7270cddc01ea863818a8621ca8\n'
         b'parent 20a103cc90135494162e819f98d0edfc1f1fba6b',
         b'\nauthor Victor Stinner <*****@*****.**> 14213',
         b'10738',
         b' +0100\ncommitter Victor Stinner <*****@*****.**> 14213',
         b'10738 +0100',
         b'\n\nStreamWriter: close() now clears the reference to the transport\n\n'
         b'StreamWriter now raises an exception if it is closed: write(), writelines(),\n'
         b'write_eof(), can_write_eof(), get_extra_info(), drain().\n'
     ]
     self.assertEqual(b''.join(expected), b''.join(res))
Example #4
0
    def get_git_author(self, ctx):
        # hg authors might not have emails
        author = ctx.user()

        # see if a translation exists
        author = self.author_map.get(author, author)

        # check for git author pattern compliance
        a = RE_GIT_AUTHOR.match(author)

        if a:
            name = a.group(1)
            email = a.group(2)
            if a.group(3) != None and len(a.group(3)) != 0:
                name += ' ext:(' + urllib.quote(a.group(3)) + ')'
            author = self.get_valid_git_username_email(name) + ' <' + self.get_valid_git_username_email(email) + '>'
        elif '@' in author:
            author = self.get_valid_git_username_email(author) + ' <' + self.get_valid_git_username_email(author) + '>'
        else:
            author = self.get_valid_git_username_email(author) + ' <none@none>'

        if 'author' in ctx.extra():
            author = "".join(apply_delta(author, ctx.extra()['author']))

        return author
    def get_git_author(self, ctx):
        # hg authors might not have emails
        author = ctx.user()

        # see if a translation exists
        if author in self.author_map:
            author = self.author_map[author]

        # check for git author pattern compliance
        regex = re.compile('^(.*?) ?\<(.*?)(?:\>(.*))?$')
        a = regex.match(author)

        if a:
            name = self.get_valid_git_username_email(a.group(1))
            email = self.get_valid_git_username_email(a.group(2))
            if a.group(3) != None and len(a.group(3)) != 0:
                name += ' ext:(' + urllib.quote(a.group(3)) + ')'
            author = self.get_valid_git_username_email(
                name) + ' <' + self.get_valid_git_username_email(email) + '>'
        elif '@' in author:
            author = self.get_valid_git_username_email(
                author) + ' <' + self.get_valid_git_username_email(
                    author) + '>'
        else:
            author = self.get_valid_git_username_email(author) + ' <none@none>'

        if 'author' in ctx.extra():
            author = "".join(apply_delta(author, ctx.extra()['author']))

        return author
Example #6
0
    def get_git_author(self, ctx):
        # hg authors might not have emails
        author = ctx.user()

        # see if a translation exists
        author = self.author_map.get(author, author)

        # check for git author pattern compliance
        a = RE_GIT_AUTHOR.match(author)

        if a:
            name = self.get_valid_git_username_email(a.group(1))
            email = self.get_valid_git_username_email(a.group(2))
            if a.group(3) != None and len(a.group(3)) != 0:
                name += ' ext:(' + urllib.quote(a.group(3)) + ')'
            author = self.get_valid_git_username_email(
                name) + ' <' + self.get_valid_git_username_email(email) + '>'
        elif '@' in author:
            author = self.get_valid_git_username_email(
                author) + ' <' + self.get_valid_git_username_email(
                    author) + '>'
        else:
            author = self.get_valid_git_username_email(author) + ' <none@none>'

        if 'author' in ctx.extra():
            author = "".join(apply_delta(author, ctx.extra()['author']))

        return author
Example #7
0
    def get_git_author(self, ctx):
        # hg authors might not have emails
        author = ctx.user()

        # check for git author pattern compliance
        regex = re.compile('^(.*?) \<(.*?)\>(.*)$')
        a = regex.match(author)

        if a:
            name = a.group(1)
            email = a.group(2)
            if len(a.group(3)) > 0:
                name += ' ext:(' + urllib.quote(a.group(3)) + ')'
            author = name + ' <' + email + '>'
        elif '<' in author:
	    # add authors with a missing closing bracket
            regex = re.compile('^(.*?) \<(.*)$')
            a = regex.match(author)

            if a:
                name = a.group(1)
                email = a.group(2)
                author = name + ' <' + email + '>'
        elif '@' in author:
            author = author + ' <' + author + '>'
        else:
            author = author + ' <none@none>'

        if 'author' in ctx.extra():
            author = "".join(apply_delta(author, ctx.extra()['author']))

        return author
Example #8
0
    def get_git_message(self, ctx):
        extra = ctx.extra()

        message = ctx.description() + "\n"

        # TODO: convert changelog ids
        if 'message' in extra:
            message = "".join(apply_delta(message, extra['message']))

        message = replace_hg_tags(self._map_hg_real, self._map_hg_short,
                                  message)
        return message
Example #9
0
    def get_git_author(self, ctx):
        # hg authors might not have emails
        author = ctx.user()

        # check for git author pattern compliance
        regex = re.compile('^(.*?) \<(.*?)\>(.*)$')
        a = regex.match(author)

        if a:
            name = a.group(1)
            email = a.group(2)
            if len(a.group(3)) > 0:
                name += ' ext:(' + urllib.quote(a.group(3)) + ')'
            author = name + ' <' + email + '>'
        else:
            author = author + ' <none@none>'

        if 'author' in ctx.extra():
            author = "".join(apply_delta(author, ctx.extra()['author']))

        return author
Example #10
0
    def get_git_message(self, ctx):
        extra = ctx.extra()

        message = ctx.description() + "\n"
        if 'message' in extra:
            message = "".join(apply_delta(message, extra['message']))

        # HG EXTRA INFORMATION
        add_extras = False
        extra_message = ''
        if not ctx.branch() == 'default':
            add_extras = True
            extra_message += "branch : " + ctx.branch() + "\n"

        renames = []
        for f in ctx.files():
            if f not in ctx.manifest():
                continue
            rename = ctx.filectx(f).renamed()
            if rename:
                renames.append((rename[0], f))

        if renames:
            add_extras = True
            for oldfile, newfile in renames:
                extra_message += "rename : " + oldfile + " => " + newfile + "\n"

        for key, value in extra.iteritems():
            if key in ('author', 'committer', 'encoding', 'message', 'branch',
                       'hg-git'):
                continue
            else:
                add_extras = True
                extra_message += "extra : " + key + " : " + urllib.quote(
                    value) + "\n"

        if add_extras:
            message += "\n--HG--\n" + extra_message

        return message
Example #11
0
    def get_git_message(self, ctx):
        extra = ctx.extra()

        message = ctx.description() + "\n"
        if 'message' in extra:
            message = "".join(apply_delta(message, extra['message']))

        # HG EXTRA INFORMATION
        add_extras = False
        extra_message = ''
        if not ctx.branch() == 'default':
            add_extras = True
            extra_message += "branch : " + ctx.branch() + "\n"

        renames = []
        for f in ctx.files():
            if f not in ctx.manifest():
                continue
            rename = ctx.filectx(f).renamed()
            if rename:
                renames.append((rename[0], f))

        if renames:
            add_extras = True
            for oldfile, newfile in renames:
                extra_message += "rename : " + oldfile + " => " + newfile + "\n"

        for key, value in extra.iteritems():
            if key in ('author', 'committer', 'encoding', 'message', 'branch',
                       'hg-git'):
                continue
            else:
                add_extras = True
                extra_message += "extra : " + key + " : " + urllib.quote(
                    value) + "\n"

        if add_extras:
            message += "\n--HG--\n" + extra_message

        return message
Example #12
0
    def get_git_author(self, ctx):
        # hg authors might not have emails
        author = ctx.user()

        # check for git author pattern compliance
        regex = re.compile("^(.*?) ?\<(.*?)(?:\>(.*))?$")
        a = regex.match(author)

        if a:
            name = a.group(1)
            email = a.group(2)
            if a.group(3) != None and len(a.group(3)) != 0:
                name += " ext:(" + urllib.quote(a.group(3)) + ")"
            author = self.get_valid_git_username_email(name) + " <" + self.get_valid_git_username_email(email) + ">"
        elif "@" in author:
            author = self.get_valid_git_username_email(author) + " <" + self.get_valid_git_username_email(author) + ">"
        else:
            author = self.get_valid_git_username_email(author) + " <none@none>"

        if "author" in ctx.extra():
            author = "".join(apply_delta(author, ctx.extra()["author"]))

        return author
Example #13
0
 def _test_roundtrip(self, base, target):
     self.assertEquals(target, "".join(apply_delta(base, create_delta(base, target))))
Example #14
0
 def _test_roundtrip(self, base, target):
     self.assertEqual(target,
                       ''.join(apply_delta(base, create_delta(base, target))))
Example #15
0
 def _test_roundtrip(self, base, target):
     self.assertEquals([target],
         apply_delta(base, create_delta(base, target)))