brz diff --using does not work with colordiff

Bug #1847915 reported by Sam Bull
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Breezy
Fix Released
Medium
Jelmer Vernooij

Bug Description

When using "brz diff --using=colordiff", I get mangled output. When using "brz diff | colordiff", everything works correctly. So, --using seems to pass the data through in a different format, which colordiff fails to parse correctly:

Mangled output:

> brz diff --using=colordiff
=== modified file 'web/common.py'
25d24
< from web.utils.user_agent import UA_languages
=== modified file 'web/translations/zh/LC_MESSAGES/messages.po'
1016a1017,1035
> #: web/templates/logged_out/install-manually.html:74
> msgid "Do you see an error?"
> msgstr ""
>
> #: web/templates/logged_out/install-manually.html:75
> msgid ""
> "If your version of Chrome is disabling the plugin and showing you a "
> "message similar to the one shown here, you will need to download and "
> "install the alternative version of Kopernio plugin .crx file."
> msgstr ""
>
> #: web/templates/logged_out/install-manually.html:78
> msgid "Download the alternative version"
> msgstr ""
>
> #: web/templates/logged_out/install-manually.html:81
> msgid "Then repeat steps 2 to 5."
> msgstr ""
>
=== removed file 'web/utils/test/test_user_agent.py'
--- old/web/utils/test/test_user_agent.py 2019-08-05 12:49:17 +0000
+++ new/web/utils/test/test_user_agent.py 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
-import pytest
-
-import web
-from web.utils.user_agent import UA_languages
-
-BASE_CASE = "fr-CH"
-HAS_COMMA = "fr-CH,"
-LIST = "fr-CH, fr-CB"
-
-
-@pytest.fixture()
-def client():
- app = web.app
- app.config["WTF_CSRF_ENABLED"] = False
- app.config["TESTING"] = True
- yield app.test_client()
-
-
-@pytest.mark.parametrize("ua_languages_str", (BASE_CASE, HAS_COMMA, LIST))
-def test_ua_language(client, ua_languages_str):
- app = web.app
- with app.test_request_context("/", headers=[("Accept-Language", ua_languages_str)]):
- client.get()
- assert UA_languages() == ["fr"]
-
-
-def test_ua_multiple_languages_returned(client):
- app = web.app
- ua_languages_str = "fr-CH, zh-TT"
- with app.test_request_context("/", headers=[("Accept-Language", ua_languages_str)]):
- client.get()
- assert "fr" in UA_languages()
- assert "zh" in UA_languages()
- assert "tt" not in UA_languages()

=== removed file 'web/utils/user_agent.py'
--- old/web/utils/user_agent.py 2019-08-05 12:49:17 +0000
+++ new/web/utils/user_agent.py 1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
-from flask import request
-
-
-def UA_languages():
- """
- This returns a list of languages without the locale
- :return: list of strings
- """
-
- # retrieve the languages as a list from the request header
- languages = request.headers.get("Accept-Language", "").lower().split(",")
-
- # remove spaces
- cleaned = list(map(lambda item: item.strip(), languages))
-
- # remove empty list items
- cleaned = [item for item in cleaned if item]
-
- # strip the locale
- cleaned = [language_locale.split("-")[0] for language_locale in cleaned]
-
- return list(set(cleaned))

Correct version:

> brz diff | colordiff
=== modified file 'web/common.py'
--- old/web/common.py 2019-10-03 11:13:31 +0000
+++ new/web/common.py 2019-10-03 11:21:06 +0000
@@ -22,7 +22,6 @@
 from web.settings import CHROME_EXTENSIONID
 from web.utils.ab_test import ABTestView, ABTestCase, abtest_analytics, ab_test, ab_finished
 from web.utils.i18n import get_available_locales
-from web.utils.user_agent import UA_languages

 # Configure babel
 babel = Babel(app)

=== modified file 'web/translations/zh/LC_MESSAGES/messages.po'
--- old/web/translations/zh/LC_MESSAGES/messages.po 2019-09-11 11:03:19 +0000
+++ new/web/translations/zh/LC_MESSAGES/messages.po 2019-10-03 11:15:28 +0000
@@ -1014,6 +1014,25 @@
 msgid "Select your institution and create a free Kopernio account"
 msgstr "选择您的组织机构,创建一个免费的Kopernio帐户吧"

+#: web/templates/logged_out/install-manually.html:74
+msgid "Do you see an error?"
+msgstr ""
+
+#: web/templates/logged_out/install-manually.html:75
+msgid ""
+"If your version of Chrome is disabling the plugin and showing you a "
+"message similar to the one shown here, you will need to download and "
+"install the alternative version of Kopernio plugin .crx file."
+msgstr ""
+
+#: web/templates/logged_out/install-manually.html:78
+msgid "Download the alternative version"
+msgstr ""
+
+#: web/templates/logged_out/install-manually.html:81
+msgid "Then repeat steps 2 to 5."
+msgstr ""
+
 #: web/templates/logged_out/install-manually.html:76
 msgid "Click to see your newly installed Kopernio button in action!"
 msgstr "单击观看新安装的Kopernio按钮发挥作用!"

=== removed file 'web/utils/test/test_user_agent.py'
--- old/web/utils/test/test_user_agent.py 2019-08-05 12:49:17 +0000
+++ new/web/utils/test/test_user_agent.py 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
-import pytest
-
-import web
-from web.utils.user_agent import UA_languages
-
-BASE_CASE = "fr-CH"
-HAS_COMMA = "fr-CH,"
-LIST = "fr-CH, fr-CB"
-
-
-@pytest.fixture()
-def client():
- app = web.app
- app.config["WTF_CSRF_ENABLED"] = False
- app.config["TESTING"] = True
- yield app.test_client()
-
-
-@pytest.mark.parametrize("ua_languages_str", (BASE_CASE, HAS_COMMA, LIST))
-def test_ua_language(client, ua_languages_str):
- app = web.app
- with app.test_request_context("/", headers=[("Accept-Language", ua_languages_str)]):
- client.get()
- assert UA_languages() == ["fr"]
-
-
-def test_ua_multiple_languages_returned(client):
- app = web.app
- ua_languages_str = "fr-CH, zh-TT"
- with app.test_request_context("/", headers=[("Accept-Language", ua_languages_str)]):
- client.get()
- assert "fr" in UA_languages()
- assert "zh" in UA_languages()
- assert "tt" not in UA_languages()

=== removed file 'web/utils/user_agent.py'
--- old/web/utils/user_agent.py 2019-08-05 12:49:17 +0000
+++ new/web/utils/user_agent.py 1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
-from flask import request
-
-
-def UA_languages():
- """
- This returns a list of languages without the locale
- :return: list of strings
- """
-
- # retrieve the languages as a list from the request header
- languages = request.headers.get("Accept-Language", "").lower().split(",")
-
- # remove spaces
- cleaned = list(map(lambda item: item.strip(), languages))
-
- # remove empty list items
- cleaned = [item for item in cleaned if item]
-
- # strip the locale
- cleaned = [language_locale.split("-")[0] for language_locale in cleaned]
-
- return list(set(cleaned))

Tags: diff

Related branches

Jelmer Vernooij (jelmer)
Changed in brz:
status: New → Triaged
importance: Undecided → Medium
Jelmer Vernooij (jelmer)
Changed in brz:
status: Triaged → In Progress
assignee: nobody → Jelmer Vernooij (jelmer)
milestone: none → 3.0.2
Jelmer Vernooij (jelmer)
Changed in brz:
status: In Progress → Fix Committed
tags: added: diff
Changed in brz:
milestone: 3.0.2 → 3.1.0
Jelmer Vernooij (jelmer)
Changed in brz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.