Changeset - 4e2e6371f79a
[Not reviewed]
default
0 4 0
Mads Kiilerich - 9 years ago 2016-09-06 00:51:18
madski@unity3d.com
helpers: in urlify_text, use <br> for newlines in pre-formatted text so it can be cut'n'pasted correctly

Before, when copying the preformatted nice looking ASCII-artsy text in a PR or
changeset description from a browser to a text editor, it would be pasted as
text without newline. Simply put, copy/paste ignores that it is inside a <pre>
/ white-space:pre-wrap section.

Instead, translate newlines to <br> which always translates to a newline when
pasted.
4 files changed with 26 insertions and 52 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/helpers.py
Show inline comments
 
@@ -1281,48 +1281,49 @@ def _urlify_text(s):
 

	
 

	
 
def urlify_text(s, repo_name=None, link_=None, truncate=None, stylize=False, truncatef=truncate):
 
    """
 
    Parses given text message and make literal html with markup.
 
    The text will be truncated to the specified length.
 
    Hashes are turned into changeset links to specified repository.
 
    URLs links to what they say.
 
    Issues are linked to given issue-server.
 
    If link_ is provided, all text not already linking somewhere will link there.
 
    """
 
    if truncate is None:
 
        s = s.rstrip()
 
    else:
 
        s = truncatef(s, truncate, whole_word=True)
 
    s = html_escape(s)
 
    if repo_name is not None:
 
        s = urlify_changesets(s, repo_name)
 
    if stylize:
 
        s = desc_stylize(s)
 
    s = _urlify_text(s)
 
    if repo_name is not None:
 
        s = urlify_issues(s, repo_name, link_)
 
    s = MENTIONS_REGEX.sub(_mentions_replace, s)
 
    s = s.replace('\r\n', '<br/>').replace('\n', '<br/>')
 
    return literal(s)
 

	
 

	
 
def _urlify_changeset_replace_f(repo_name):
 
    from pylons import url  # doh, we need to re-import url to mock it later
 
    def urlify_changeset_replace(match_obj):
 
        rev = match_obj.group(0)
 
        return '<a class="revision-link" href="%(url)s">%(rev)s</a>' % {
 
         'url': url('changeset_home', repo_name=repo_name, revision=rev),
 
         'rev': rev,
 
        }
 
    return urlify_changeset_replace
 

	
 

	
 
urilify_changeset_re = r'(?:^|(?<=[\s(),]))([0-9a-fA-F]{12,40})(?=$|\s|[.,:()])'
 

	
 
def urlify_changesets(text_, repo_name):
 
    """
 
    Extract revision ids from changeset and make link from them
 
    """
 
    urlify_changeset_replace = _urlify_changeset_replace_f(repo_name)
 
    return re.sub(urilify_changeset_re, urlify_changeset_replace, text_)
 

	
 

	
kallithea/tests/functional/test_files.py
Show inline comments
 
@@ -78,53 +78,53 @@ class TestFilesController(TestController
 

	
 
    def test_index_paging(self):
 
        self.log_user()
 

	
 
        for r in [(73, 'a066b25d5df7016b45a41b7e2a78c33b57adc235'),
 
                  (92, 'cc66b61b8455b264a7a8a2d8ddc80fcfc58c221e'),
 
                  (109, '75feb4c33e81186c87eac740cee2447330288412'),
 
                  (1, '3d8f361e72ab303da48d799ff1ac40d5ac37c67e'),
 
                  (0, 'b986218ba1c9b0d6a259fac9b050b1724ed8e545')]:
 

	
 
            response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=HG_REPO,
 
                                    revision=r[1],
 
                                    f_path='/'))
 

	
 
            response.mustcontain("""@ r%s:%s""" % (r[0], r[1][:12]))
 

	
 
    def test_file_source(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=HG_REPO,
 
                                    revision='8911406ad776fdd3d0b9932a2e89677e57405a48',
 
                                    f_path='vcs/nodes.py'))
 

	
 
        response.mustcontain("""<div class="commit">Partially implemented <a class="issue-tracker-link" href="https://issues.example.com/vcs_test_hg/issue/16">#16</a>. filecontent/commit message/author/node name are safe_unicode now.
 
In addition some other __str__ are unicode as well
 
Added test for unicode
 
Improved test to clone into uniq repository.
 
removed extra unicode conversion in diff.</div>
 
        response.mustcontain("""<div class="commit">Partially implemented <a class="issue-tracker-link" href="https://issues.example.com/vcs_test_hg/issue/16">#16</a>. filecontent/commit message/author/node name are safe_unicode now.<br/>"""
 
"""In addition some other __str__ are unicode as well<br/>"""
 
"""Added test for unicode<br/>"""
 
"""Improved test to clone into uniq repository.<br/>"""
 
"""removed extra unicode conversion in diff.</div>
 
""")
 

	
 
        response.mustcontain("""<option selected="selected" value="8911406ad776fdd3d0b9932a2e89677e57405a48">default at 8911406ad776</option>""")
 

	
 
    def test_file_source_history(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='history',
 
                                    repo_name=HG_REPO,
 
                                    revision='tip',
 
                                    f_path='vcs/nodes.py'),
 
                                extra_environ={'HTTP_X_PARTIAL_XHR': '1'},)
 
        assert response.body == HG_NODE_HISTORY
 

	
 
    def test_file_source_history_git(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='history',
 
                                    repo_name=GIT_REPO,
 
                                    revision='master',
 
                                    f_path='vcs/nodes.py'),
 
                                extra_environ={'HTTP_X_PARTIAL_XHR': '1'},)
 
        assert response.body == GIT_NODE_HISTORY
 

	
 
    def test_file_annotation(self):
 
        self.log_user()
kallithea/tests/models/test_dump_html_mails.ref.html
Show inline comments
 
@@ -73,51 +73,49 @@ View Comment: http://comment.org
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td>
 
<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="#f9f9f9" style="border:1px solid #ddd;border-radius:4px">
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-weight:600;color:#395fa0">Opinionated User (jsmith)</div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="repo_target">repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -232,51 +230,49 @@ View Comment: http://comment.org
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td>
 
<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="#f9f9f9" style="border:1px solid #ddd;border-radius:4px">
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-weight:600;color:#395fa0">Opinionated User (jsmith)</div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="repo_target">repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -409,51 +405,49 @@ View Comment: http://comment.org
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Approved
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="repo_target">repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -586,51 +580,49 @@ View Comment: http://comment.org
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Approved
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new comment.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="repo_target">repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -707,50 +699,49 @@ Subject: Test Message
 
    <tr>
 
        <td height="20px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="30px"></td>
 
        <td style="font-family:Helvetica,Arial,sans-serif;font-size:19px;line-height:24px">
 
            <span style="color:#395fa0">Message</span>
 
        </td>
 
        <td width="30px"></td>
 
    </tr>
 
    <tr>
 
        <td height="20px" colspan="3"></td>
 
    </tr>
 
</table>
 
                    </td>
 
                </tr>
 
                <tr>
 
                    <td height="30px" colspan="3"></td>
 
                </tr>
 
                <tr>
 
                    <td></td>
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the body of the test message
 
 - nothing interesting here except indentation.</div></td>
 
        <td style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the body of the test message<br/> - nothing interesting here except indentation.</div></td>
 
    </tr>
 
</table>
 
                    </td>
 
                    <td></td>
 
                </tr>
 
                <tr>
 
                    <td height="30px" colspan="3"></td>
 
                </tr>
 
            </table>
 
        </td>
 
        <td width="30px"></td>
 
    </tr>
 
</table>
 
<!--/body-->
 
<!--/html-->
 
<hr/>
 
<hr/>
 
<h1>registration</h1>
 
<pre>
 
From: u1
 
To: u2@example.com
 
Subject: New user newbie registered
 
</pre>
 
<hr/>
 
@@ -965,50 +956,49 @@ View Pull Request: http://pr.org/7
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                at
 
                <span style="color:#395fa0">trunk</span>:
 
            </div>
 
            <div>
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://pr.org/7">#7</a>
 
                "<span style="color:#395fa0">The Title</span>"
 
                by
 
                <span style="color:#395fa0">u2 u3 (u2)</span>.
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Description:
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is awesome because it does stuff
 
 - please approve indented!</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is awesome because it does stuff<br/> - please approve indented!</div></div>
 
        </td>
 
    </tr>
 
    <tr><td height="15px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>Changesets:</div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px"></td></tr>
 

	
 
    <tr>
 
        <td style="font-family:Helvetica,Arial,sans-serif">
 
            <ul style="color:#395fa0;padding-left:15px;margin:0">
 
                    <li>
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc">
 
                            Introduce one and two
 
                        </a>
 
                    </li>
 
                    <li>
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed">
 
                            Make one plus two equal tree
 
                        </a>
 
@@ -1139,50 +1129,49 @@ View Pull Request: http://pr.org/7
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                at
 
                <span style="color:#395fa0">trunk</span>:
 
            </div>
 
            <div>
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://pr.org/7">#7</a>
 
                "<span style="color:#395fa0">The Title</span>"
 
                by
 
                <span style="color:#395fa0">u2 u3 (u2)</span>.
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Description:
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is awesome because it does stuff
 
 - please approve indented!</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is awesome because it does stuff<br/> - please approve indented!</div></div>
 
        </td>
 
    </tr>
 
    <tr><td height="15px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>Changesets:</div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px"></td></tr>
 

	
 
    <tr>
 
        <td style="font-family:Helvetica,Arial,sans-serif">
 
            <ul style="color:#395fa0;padding-left:15px;margin:0">
 
                    <li>
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc">
 
                            Introduce one and two
 
                        </a>
 
                    </li>
 
                    <li>
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed">
 
                            Make one plus two equal tree
 
                        </a>
 
@@ -1296,51 +1285,49 @@ View Comment: http://pr.org/comment
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td>
 
<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="#f9f9f9" style="border:1px solid #ddd;border-radius:4px">
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-weight:600;color:#395fa0">Opinionated User (jsmith)</div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
 
@@ -1461,51 +1448,49 @@ View Comment: http://pr.org/comment
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td>
 
<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="#f9f9f9" style="border:1px solid #ddd;border-radius:4px">
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-weight:600;color:#395fa0">Opinionated User (jsmith)</div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
 
@@ -1644,51 +1629,49 @@ View Comment: http://pr.org/comment
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Under Review
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
 
@@ -1827,51 +1810,49 @@ View Comment: http://pr.org/comment
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Under Review
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
 
@@ -2009,51 +1990,49 @@ View Comment: http://pr.org/comment
 
    <tr>
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        The pull request has been closed.
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
 
@@ -2191,51 +2170,49 @@ View Comment: http://pr.org/comment
 
    <tr>
 
        <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        The pull request has been closed.
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
 
@@ -2379,51 +2356,49 @@ View Comment: http://pr.org/comment
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Under Review
 
                    </div>
 
                    <div style="font-weight:600">
 
                        The pull request has been closed.
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
 
@@ -2567,51 +2542,49 @@ View Comment: http://pr.org/comment
 
            <td height="10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Under Review
 
                    </div>
 
                    <div style="font-weight:600">
 
                        The pull request has been closed.
 
                    </div>
 
            </td>
 
            <td width="20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!
 

	
 
 - and indented on second line</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">Me too!<br/><br/> - and indented on second line</div></div>
 
        </td>
 
        <td width="20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Pull request from
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="https://dev.org/repo">https://dev.org/repo</a>
 
                branch
 
                <span style="color:#395fa0">devbranch</span>
 
                to
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                branch
kallithea/tests/other/test_libs.py
Show inline comments
 
@@ -287,84 +287,84 @@ class TestLibs(TestController):
 
        return URL_PAT.sub(url_func, text)
 

	
 
    @parametrize('sample,expected', [
 
      ("",
 
       ""),
 
      ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68",
 
       """git-svn-id: <a href="https://svn.apache.org/repos/asf/libcloud/trunk@1441655">https://svn.apache.org/repos/asf/libcloud/trunk@1441655</a> 13f79535-47bb-0310-9956-ffa450edef68"""),
 
      ("from rev 000000000000",
 
       """from rev url[000000000000]"""),
 
      ("from rev 000000000000123123 also rev 000000000000",
 
       """from rev url[000000000000123123] also rev url[000000000000]"""),
 
      ("this should-000 00",
 
       """this should-000 00"""),
 
      ("longtextffffffffff rev 123123123123",
 
       """longtextffffffffff rev url[123123123123]"""),
 
      ("rev ffffffffffffffffffffffffffffffffffffffffffffffffff",
 
       """rev ffffffffffffffffffffffffffffffffffffffffffffffffff"""),
 
      ("ffffffffffff some text traalaa",
 
       """url[ffffffffffff] some text traalaa"""),
 
       ("""Multi line
 
       123123123123
 
       some text 123123123123
 
       sometimes !
 
       """,
 
       """Multi line\n"""
 
       """       url[123123123123]\n"""
 
       """       some text url[123123123123]\n"""
 
       """Multi line<br/>"""
 
       """       url[123123123123]<br/>"""
 
       """       some text url[123123123123]<br/>"""
 
       """       sometimes !"""),
 
    ])
 
    def test_urlify_changesets(self, sample, expected):
 
        def fake_url(self, *args, **kwargs):
 
            return '/some-url'
 

	
 
        expected = self._quick_url(expected)
 

	
 
        with mock.patch('pylons.url', fake_url):
 
            from kallithea.lib.helpers import urlify_text
 
            assert urlify_text(sample, 'repo_name') == expected
 

	
 
    @parametrize('sample,expected,url_', [
 
      ("",
 
       "",
 
       ""),
 
      ("https://svn.apache.org/repos",
 
       """url[https://svn.apache.org/repos]""",
 
       "https://svn.apache.org/repos"),
 
      ("http://svn.apache.org/repos",
 
       """url[http://svn.apache.org/repos]""",
 
       "http://svn.apache.org/repos"),
 
      ("from rev a also rev http://google.com",
 
       """from rev a also rev url[http://google.com]""",
 
       "http://google.com"),
 
      ("http://imgur.com/foo.gif inline http://imgur.com/foo.gif ending http://imgur.com/foo.gif",
 
       """url[http://imgur.com/foo.gif] inline url[http://imgur.com/foo.gif] ending url[http://imgur.com/foo.gif]""",
 
       "http://imgur.com/foo.gif"),
 
      ("""Multi line
 
       https://foo.bar.example.com
 
       some text lalala""",
 
       """Multi line\n"""
 
       """       url[https://foo.bar.example.com]\n"""
 
       """Multi line<br/>"""
 
       """       url[https://foo.bar.example.com]<br/>"""
 
       """       some text lalala""",
 
       "https://foo.bar.example.com"),
 
      ("@mention @someone",
 
       """<b>@mention</b> <b>@someone</b>""",
 
       ""),
 
      ("deadbeefcafe 123412341234",
 
       """<a class="revision-link" href="/repo_name/changeset/deadbeefcafe">deadbeefcafe</a> <a class="revision-link" href="/repo_name/changeset/123412341234">123412341234</a>""",
 
       ""),
 
      # tags are covered by test_tag_extractor
 
    ])
 
    def test_urlify_test(self, sample, expected, url_):
 
        from kallithea.lib.helpers import urlify_text
 
        expected = self._quick_url(expected,
 
                                   tmpl="""<a href="%s">%s</a>""", url_=url_)
 
        assert urlify_text(sample, 'repo_name', stylize=True) == expected
 

	
 
    @parametrize('sample,expected', [
 
      ("deadbeefcafe @mention, and http://foo.bar/ yo",
 
       """<a class="message-link" href="#the-link"></a>"""
 
       """<a class="revision-link" href="/repo_name/changeset/deadbeefcafe">deadbeefcafe</a>"""
 
       """<a class="message-link" href="#the-link"> <b>@mention</b>, and </a>"""
 
       """<a href="http://foo.bar/">http://foo.bar/</a>"""
 
       """<a class="message-link" href="#the-link"> yo</a>"""),
 
    ])
0 comments (0 inline, 0 general)