Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 6612:94bf2f307b75 stable
topic: check that topic namespace names are human-readable like topics
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 11 Dec 2023 16:51:27 -0300 |
parents | 1dc008b6ad21 |
children | e0596b012b69 4443117fdf94 |
comparison
equal
deleted
inserted
replaced
6611:1dc008b6ad21 | 6612:94bf2f307b75 |
---|---|
1839 if not tns: | 1839 if not tns: |
1840 raise error.Abort(_(b"topic namespace cannot consist entirely of whitespace")) | 1840 raise error.Abort(_(b"topic namespace cannot consist entirely of whitespace")) |
1841 if b'/' in tns: | 1841 if b'/' in tns: |
1842 raise error.Abort(_(b"topic namespace cannot contain '/' character")) | 1842 raise error.Abort(_(b"topic namespace cannot contain '/' character")) |
1843 scmutil.checknewlabel(repo, tns, b'topic namespace') | 1843 scmutil.checknewlabel(repo, tns, b'topic namespace') |
1844 | |
1845 helptxt = _(b"topic namespace names can only consist of alphanumeric, " | |
1846 b"'-', '_' and '.' characters") | |
1847 try: | |
1848 utns = encoding.unifromlocal(tns) | |
1849 except error.Abort: | |
1850 # Maybe we should allow these topic names as well, as long as they | |
1851 # don't break any other rules | |
1852 utns = '' | |
1853 rmatch = re.match(r'[-_.\w]+', utns, re.UNICODE) | |
1854 if not utns or not rmatch or rmatch.group(0) != utns: | |
1855 raise compat.InputError(_(b"invalid topic namespace name: '%s'") % tns, hint=helptxt) | |
1844 ctns = repo.currenttns | 1856 ctns = repo.currenttns |
1845 _changecurrenttns(repo, tns) | 1857 _changecurrenttns(repo, tns) |
1846 if ctns == b'none' and tns != b'none': | 1858 if ctns == b'none' and tns != b'none': |
1847 repo.ui.status(_(b'marked working directory as topic namespace: %s\n') | 1859 repo.ui.status(_(b'marked working directory as topic namespace: %s\n') |
1848 % tns) | 1860 % tns) |