changeset 6656:d3668c704d40 stable

topic: use the appropriate functions to change topic and tns on wdir update This way we don't write the default topic/tns values into the files. It's safer this way if any of the default values change at some point (as it did for topic namespaces).
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 18 Jan 2024 14:32:41 -0300
parents 81fe0a498447
children 1c998ed77597
files hgext3rd/topic/__init__.py tests/test-namespaces.t
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Sat Jan 27 17:36:39 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Thu Jan 18 14:32:41 2024 -0300
@@ -1704,10 +1704,10 @@
             if pctx.phase() > phases.public:
                 tns = pctx.topic_namespace()
                 t = pctx.topic()
-            repo.vfs.write(b'topic-namespace', tns)
+            _changecurrenttns(repo, tns)
             if tns != b'none' and tns != otns:
                 repo.ui.status(_(b"switching to topic-namespace %s\n") % tns)
-            repo.vfs.write(b'topic', t)
+            _changecurrenttopic(repo, t)
             if t and t != ot:
                 repo.ui.status(_(b"switching to topic %s\n") % t)
             if ot and not t:
--- a/tests/test-namespaces.t	Sat Jan 27 17:36:39 2024 -0300
+++ b/tests/test-namespaces.t	Thu Jan 18 14:32:41 2024 -0300
@@ -94,8 +94,12 @@
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg debug-topic-namespace
   none
+  $ test -f .hg/topic-namespace
+  [1]
   $ hg topics
      feature (1 changesets)
+  $ test -f .hg/topic
+  [1]
   $ hg up 0
   switching to topic-namespace alice
   switching to topic feature
@@ -104,6 +108,8 @@
   alice
   $ hg topics
    * feature (1 changesets)
+  $ cat .hg/topic
+  feature (no-eol)
 
 Updating to a topic namespace is not supported