Mercurial > evolve
changeset 6610:ae7c75c43f92 stable
topic: properly decode topic and topic namespace after reading from disk
Looks like we forgot that the bytes read from disk should be converted to the
local encoding. The way it's done in this patch is how branch is handled in
core.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 11 Dec 2023 16:15:10 -0300 |
parents | 536d950753e6 |
children | 1dc008b6ad21 |
files | hgext3rd/topic/__init__.py tests/test-namespaces.t tests/test-topic.t |
diffstat | 3 files changed, 24 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Mon Oct 23 15:27:57 2023 -0300 +++ b/hgext3rd/topic/__init__.py Mon Dec 11 16:15:10 2023 -0300 @@ -693,7 +693,8 @@ @property def currenttns(self): - return self.vfs.tryread(b'topic-namespace') or b'none' + tns = self.vfs.tryread(b'topic-namespace') or b'none' + return encoding.tolocal(tns) @util.propertycache def _topiccache(self): @@ -712,7 +713,8 @@ @property def currenttopic(self): - return self.vfs.tryread(b'topic') + topic = self.vfs.tryread(b'topic') + return encoding.tolocal(topic) # overwritten at the instance level by topicmap.py _autobranchmaptopic = True
--- a/tests/test-namespaces.t Mon Oct 23 15:27:57 2023 -0300 +++ b/tests/test-namespaces.t Mon Dec 11 16:15:10 2023 -0300 @@ -31,6 +31,18 @@ $ hg log -r 'wdir()' -T '{fqbn}\n' default//space-name/feature +Non-ascii topic namespace name + + $ hg debug-topic-namespace --clear + $ hg --encoding utf-8 debug-topic-namespace æ + marked working directory as topic namespace: \xc3\xa6 (esc) + $ hg --encoding utf-8 debug-topic-namespaces + æ (esc) + $ hg --encoding ascii debug-topic-namespaces + ? (esc) + $ hg --encoding latin1 debug-topic-namespaces + \xe6 (esc) + $ hg branches $ hg debug-topic-namespace --clear
--- a/tests/test-topic.t Mon Oct 23 15:27:57 2023 -0300 +++ b/tests/test-topic.t Mon Dec 11 16:15:10 2023 -0300 @@ -322,11 +322,16 @@ Non-ascii topic name + $ hg topic --clear + clearing empty topic "topicflag" $ hg --encoding utf-8 topic æ - $ hg topics - * \xc3\xa6 (0 changesets) (esc) + marked working directory as topic: \xc3\xa6 (esc) + $ hg --encoding utf-8 topics + * æ (0 changesets) (esc) + $ hg --encoding ascii topics + * ? (0 changesets) (esc) $ hg --encoding latin1 topics - * \xc3\xa6 (0 changesets) (esc) + * \xe6 (0 changesets) (esc) $ hg --encoding utf-8 topic © abort: invalid topic name: '\xc2\xa9' (esc)