Mercurial > evolve
diff hgext3rd/topic/__init__.py @ 6614:e0596b012b69
branching: merge with stable
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 16 Dec 2023 13:23:38 -0300 |
parents | 6116a0208449 94bf2f307b75 |
children | 9e442e116621 |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Sat Nov 11 16:21:23 2023 -0300 +++ b/hgext3rd/topic/__init__.py Sat Dec 16 13:23:38 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 @@ -1096,7 +1098,7 @@ # Have some restrictions on the topic name just like bookmark name scmutil.checknewlabel(repo, topic, b'topic') - helptxt = _(b"topic names can only consist of alphanumeric, '-'" + helptxt = _(b"topic names can only consist of alphanumeric, '-'," b" '_' and '.' characters") try: utopic = encoding.unifromlocal(topic) @@ -1843,6 +1845,18 @@ if b'/' in tns: raise error.Abort(_(b"topic namespace cannot contain '/' character")) scmutil.checknewlabel(repo, tns, b'topic namespace') + + helptxt = _(b"topic namespace names can only consist of alphanumeric, " + b"'-', '_' and '.' characters") + try: + utns = encoding.unifromlocal(tns) + except error.Abort: + # Maybe we should allow these topic names as well, as long as they + # don't break any other rules + utns = '' + rmatch = re.match(r'[-_.\w]+', utns, re.UNICODE) + if not utns or not rmatch or rmatch.group(0) != utns: + raise compat.InputError(_(b"invalid topic namespace name: '%s'") % tns, hint=helptxt) ctns = repo.currenttns _changecurrenttns(repo, tns) if ctns == b'none' and tns != b'none':