コード例 #1
0
    def test_A_Breathing(self):

        # test we can convert unicode to unicode
        phlsys_textconvert.to_unicode(unicode('hello'))

        # test we can convert str to unicode
        self.assertIsInstance(phlsys_textconvert.to_unicode('hello'), unicode)

        # test invalid characters get replaced by the replacement character
        self.assertEqual(phlsys_textconvert.to_unicode('\xFF'), u'\uFFFD')

        # test 'horizontal ellipses' as UTF8 get replaced
        self.assertEqual(phlsys_textconvert.to_unicode('\xe2\x80\xa6'),
                         u'\uFFFD\uFFFD\uFFFD')

        # test we can convert ascii to ascii
        phlsys_textconvert.ensure_ascii('hello')

        # test str stays str
        self.assertIsInstance(phlsys_textconvert.ensure_ascii('hello'), str)

        # test invalid characters get replaced by '?'
        self.assertEqual(phlsys_textconvert.ensure_ascii('\xFF'), '?')

        # test 'horizontal ellipses' as UTF8 get replaced
        self.assertEqual(phlsys_textconvert.ensure_ascii('\xe2\x80\xa6'),
                         '???')
コード例 #2
0
    def describe_new_commits(self, max_commits=100, max_size=16000):
        """Return a string description of the new commits on the branch."""
        hashes = None
        previous = None
        latest = self._review_branch.remote_branch

        if self.is_new():
            previous = self._review_branch.remote_base
        else:
            previous = self._tracking_branch.remote_branch

        hashes = self._repo.get_range_hashes(previous, latest)
        hashes.reverse()
        revisions = self._repo.make_revisions_from_hashes(hashes)

        message = ""
        count = 0
        message_size = 0
        for r in revisions:
            new_message = r.abbrev_hash + " " + r.subject + "\n"
            count += 1
            message_size += len(new_message)
            if count > max_commits or message_size > max_size:
                message += "...{num_commits} commits not shown.\n".format(
                    num_commits=len(revisions) - count + 1)
                break
            else:
                message += new_message
        return phlsys_textconvert.ensure_ascii(message)
コード例 #3
0
    def describe_new_commits(self, max_commits=100, max_size=16000):
        """Return a string description of the new commits on the branch."""
        hashes = None
        previous = None
        latest = self._review_branch.remote_branch

        if self.is_new():
            previous = self._review_branch.remote_base
        else:
            previous = self._tracking_branch.remote_branch

        hashes = self._repo.get_range_hashes(previous, latest)
        hashes.reverse()
        revisions = self._repo.make_revisions_from_hashes(hashes)

        message = ""
        count = 0
        message_size = 0
        for r in revisions:
            new_message = r.abbrev_hash + " " + r.subject + "\n"
            count += 1
            message_size += len(new_message)
            if count > max_commits or message_size > max_size:
                message += "...{num_commits} commits not shown.\n".format(
                    num_commits=len(revisions) - count + 1)
                break
            else:
                message += new_message
        return phlsys_textconvert.ensure_ascii(message)
コード例 #4
0
 def get_commit_message_from_tip(self):
     """Return string commit message from latest commit on branch."""
     hashes = self._get_commit_hashes()
     revision = phlgit_log.make_revision_from_hash(self._repo, hashes[-1])
     message = revision.subject + "\n"
     message += "\n"
     message += revision.message + "\n"
     return phlsys_textconvert.ensure_ascii(message)
コード例 #5
0
 def get_commit_message_from_tip(self):
     """Return string commit message from latest commit on branch."""
     hashes = self._get_commit_hashes()
     revision = phlgit_log.make_revision_from_hash(self._repo, hashes[-1])
     message = revision.subject + "\n"
     message += "\n"
     message += revision.message + "\n"
     return phlsys_textconvert.ensure_ascii(message)
コード例 #6
0
    def make_message_digest(self):
        """Return a string digest of the commit messages on the branch.

        The digest is comprised of the title from the earliest commit
        unique to the branch and all of the message bodies from the
        unique commits on the branch.

        """
        hashes = self._get_commit_hashes()
        revisions = self._repo.make_revisions_from_hashes(hashes)
        message = revisions[0].subject + "\n\n"
        for r in revisions:
            message += r.message
        return phlsys_textconvert.ensure_ascii(message)
コード例 #7
0
    def make_message_digest(self):
        """Return a string digest of the commit messages on the branch.

        The digest is comprised of the title from the earliest commit
        unique to the branch and all of the message bodies from the
        unique commits on the branch.

        """
        hashes = self._get_commit_hashes()
        revisions = self._repo.make_revisions_from_hashes(hashes)
        message = revisions[0].subject + "\n\n"
        for r in revisions:
            message += r.message
        return phlsys_textconvert.ensure_ascii(message)
コード例 #8
0
    def test_A_Breathing(self):

        # test we can convert unicode to unicode
        phlsys_textconvert.to_unicode(unicode('hello'))

        # test we can convert str to unicode
        self.assertIsInstance(
            phlsys_textconvert.to_unicode('hello'),
            unicode)

        # test invalid characters get replaced by the replacement character
        self.assertEqual(
            phlsys_textconvert.to_unicode('\xFF'),
            u'\uFFFD')

        # test 'horizontal ellipses' as UTF8 get replaced
        self.assertEqual(
            phlsys_textconvert.to_unicode('\xe2\x80\xa6'),
            u'\uFFFD\uFFFD\uFFFD')

        # test we can convert ascii to ascii
        phlsys_textconvert.ensure_ascii('hello')

        # test str stays str
        self.assertIsInstance(
            phlsys_textconvert.ensure_ascii('hello'),
            str)

        # test invalid characters get replaced by '?'
        self.assertEqual(
            phlsys_textconvert.ensure_ascii('\xFF'),
            '?')

        # test 'horizontal ellipses' as UTF8 get replaced
        self.assertEqual(
            phlsys_textconvert.ensure_ascii('\xe2\x80\xa6'),
            '???')
コード例 #9
0
    def describe_new_commits(self):
        """Return a string description of the new commits on the branch."""
        hashes = None
        previous = None
        latest = self._review_branch.remote_branch

        if self.is_new():
            previous = self._review_branch.remote_base
        else:
            previous = self._tracking_branch.remote_branch

        hashes = self._repo.get_range_hashes(previous, latest)
        hashes.reverse()
        revisions = self._repo.make_revisions_from_hashes(hashes)

        message = ""
        for r in revisions:
            message += r.abbrev_hash + " " + r.subject + "\n"
        return phlsys_textconvert.ensure_ascii(message)