Mercurial > evolve
changeset 6487:963471ebe26a
topic: make topic namespace use string "none" as the default/empty value
The rationale is to not let topic namespaces be confused with neither default
branch nor the actual default namespace value (which is planned to be
configurable, but probably will be local user name by default).
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 19 May 2023 10:08:19 -0300 |
parents | 0c503c521ba5 |
children | 3f30aaa067ba |
files | hgext3rd/topic/__init__.py hgext3rd/topic/common.py hgext3rd/topic/discovery.py hgext3rd/topic/revset.py tests/test-namespaces.t |
diffstat | 5 files changed, 28 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Mon May 22 20:33:39 2023 -0300 +++ b/hgext3rd/topic/__init__.py Fri May 19 10:08:19 2023 -0300 @@ -298,17 +298,17 @@ def _contexttns(self, force=False): if not force and not self.mutable(): - return b'default' + return b'none' cache = getattr(self._repo, '_tnscache', None) # topic loaded, but not enabled (eg: multiple repo in the same process) if cache is None: - return b'default' + return b'none' if self.rev() is None: # don't cache volatile ctx instances that aren't stored on-disk yet - return self.extra().get(b'topic-namespace', b'default') + return self.extra().get(b'topic-namespace', b'none') tns = cache.get(self.rev()) if tns is None: - tns = self.extra().get(b'topic-namespace', b'default') + tns = self.extra().get(b'topic-namespace', b'none') self._repo._tnscache[self.rev()] = tns return tns @@ -576,7 +576,7 @@ @property def currenttns(self): - return self.vfs.tryread(b'topic-namespace') or b'default' + return self.vfs.tryread(b'topic-namespace') or b'none' @util.propertycache def _topiccache(self): @@ -817,7 +817,7 @@ self._extra[b'topic-namespace'] = repo.currenttns else: # Default value will be dropped from extra by another hack at the changegroup level - self._extra[b'topic-namespace'] = b'default' + self._extra[b'topic-namespace'] = b'none' if constants.extrakey not in self._extra: if getattr(repo, 'currenttopic', b''): self._extra[constants.extrakey] = repo.currenttopic @@ -828,7 +828,7 @@ def wrapadd(orig, cl, manifest, files, desc, transaction, p1, p2, user, date=None, extra=None, p1copies=None, p2copies=None, filesadded=None, filesremoved=None): - if b'topic-namespace' in extra and extra[b'topic-namespace'] == b'default': + if b'topic-namespace' in extra and extra[b'topic-namespace'] == b'none': extra = extra.copy() del extra[b'topic-namespace'] if constants.extrakey in extra and not extra[constants.extrakey]: @@ -1518,14 +1518,14 @@ if repo.ui.configbool(b'_internal', b'keep-topic'): ist0 = True if ((not partial and not branchmerge) or isrebase) and not ist0: - tns = b'default' + tns = b'none' t = b'' pctx = repo[node] if pctx.phase() > phases.public: tns = pctx.topic_namespace() t = pctx.topic() repo.vfs.write(b'topic-namespace', tns) - if tns != b'default' and tns != otns: + if tns != b'none' and tns != otns: repo.ui.status(_(b"switching to topic-namespace %s\n") % tns) repo.vfs.write(b'topic', t) if t and t != ot: @@ -1651,7 +1651,7 @@ scmutil.checknewlabel(repo, tns, b'topic namespace') ctns = repo.currenttns _changecurrenttns(repo, tns) - if ctns == b'default' and tns: + if ctns == b'none' and tns: repo.ui.status(_(b'marked working directory as topic namespace: %s\n') % tns)
--- a/hgext3rd/topic/common.py Mon May 22 20:33:39 2023 -0300 +++ b/hgext3rd/topic/common.py Fri May 19 10:08:19 2023 -0300 @@ -11,21 +11,21 @@ """parse branch//namespace/topic string into branch, namespace and topic >>> parsefqbn(b'branch//topic') - ('branch', 'default', 'topic') + ('branch', 'none', 'topic') >>> parsefqbn(b'//namespace/topic') ('default', 'namespace', 'topic') >>> parsefqbn(b'branch//') - ('branch', 'default', '') + ('branch', 'none', '') >>> parsefqbn(b'//namespace/') ('default', 'namespace', '') >>> parsefqbn(b'/topic') - ('/topic', 'default', '') + ('/topic', 'none', '') >>> parsefqbn(b'//topic') - ('default', 'default', 'topic') + ('default', 'none', 'topic') >>> parsefqbn(b'branch//namespace/topic') ('branch', 'namespace', 'topic') >>> parsefqbn(b'file:///tmp/branch//') - ('file:///tmp/branch', 'default', '') + ('file:///tmp/branch', 'none', '') >>> parsefqbn(b'http://example.com/branch//namespace/topic') ('http://example.com/branch', 'namespace', 'topic') """ @@ -39,7 +39,7 @@ tns, sep, topic = other.partition(b'/') if not sep: # when there's no / in the rest of the string, there can only be topic - tns, topic = b'default', tns + tns, topic = b'none', tns return branch, tns, topic def formatfqbn(branch=b'', namespace=b'', topic=b'', short=True): @@ -70,7 +70,7 @@ """ result = b'' showbranch = True # branch and not (short and branch == b'default') - shownamespace = namespace and not (short and namespace == b'default') + shownamespace = namespace and not (short and namespace == b'none') if short and not showbranch and not shownamespace and not topic: # if there's nothing to show, show at least branch showbranch = True
--- a/hgext3rd/topic/discovery.py Mon May 22 20:33:39 2023 -0300 +++ b/hgext3rd/topic/discovery.py Fri May 19 10:08:19 2023 -0300 @@ -248,7 +248,7 @@ data = {} for b in repo.branchmap().iterbranches(): namedbranch, tns, topic = common.parsefqbn(b[0]) - if tns != b'default' or topic: + if tns != b'none' or topic: continue oldheads = [repo[n].rev() for n in b[1]] newheads = filterfn(repo, oldheads)
--- a/hgext3rd/topic/revset.py Mon May 22 20:33:39 2023 -0300 +++ b/hgext3rd/topic/revset.py Fri May 19 10:08:19 2023 -0300 @@ -25,7 +25,7 @@ def topicnamespaceset(repo, subset, x): """All changesets with the specified topic namespace or the topic namespaces of the given changesets. Without the argument, all changesets - with any non-default topic namespace. + with any non-empty topic namespace. Pattern matching is supported for `string`. See :hg:`help revisions.patterns`.
--- a/tests/test-namespaces.t Mon May 22 20:33:39 2023 -0300 +++ b/tests/test-namespaces.t Fri May 19 10:08:19 2023 -0300 @@ -20,7 +20,7 @@ $ hg debug-topic-namespace --clear $ hg debug-topic-namespaces - default + none $ hg debugtopicnamespace --clear nonsense abort: cannot use --clear when setting a topic namespace @@ -53,7 +53,7 @@ $ hg up null 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg debug-topic-namespace - default + none $ hg topics feature (1 changesets) $ hg up 0 @@ -104,7 +104,7 @@ no double slashes means it's a named branch $ hg debug-parse-fqbn foo/bar branch: foo/bar - namespace: default + namespace: none topic: Formatting @@ -120,9 +120,9 @@ default values - $ hg debug-format-fqbn -b default -n default -t '' --no-short - default//default/ - $ hg debug-format-fqbn -b default -n default -t '' --short + $ hg debug-format-fqbn -b default -n none -t '' --no-short + default//none/ + $ hg debug-format-fqbn -b default -n none -t '' --short default $ hg debug-format-fqbn -b default -n namespace -t '' --no-short @@ -130,9 +130,9 @@ $ hg debug-format-fqbn -b default -n namespace -t '' --short default//namespace/ - $ hg debug-format-fqbn -b default -n default -t topic --no-short - default//default/topic - $ hg debug-format-fqbn -b default -n default -t topic --short + $ hg debug-format-fqbn -b default -n none -t topic --no-short + default//none/topic + $ hg debug-format-fqbn -b default -n none -t topic --short default//topic $ cd ..