# HG changeset patch # User Anton Shestakov # Date 1702322110 10800 # Node ID ae7c75c43f92cdbde9c504ba622a898fb352ee53 # Parent 536d950753e6da0be83fefab615c73f43b11fbb4 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. diff -r 536d950753e6 -r ae7c75c43f92 hgext3rd/topic/__init__.py --- 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 diff -r 536d950753e6 -r ae7c75c43f92 tests/test-namespaces.t --- 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 diff -r 536d950753e6 -r ae7c75c43f92 tests/test-topic.t --- 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)