changeset 6734:c2a4e21f4aaf stable

topic: move .hg/topic-namespace file removal to a separate method
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 28 Feb 2024 15:07:52 -0300
parents 5b20bc704577
children 5b08e93a982e
files hgext3rd/topic/__init__.py
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Sun Mar 03 14:40:01 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Wed Feb 28 15:07:52 2024 -0300
@@ -715,12 +715,8 @@
             self._topic_namespaces = namespaces
             return namespaces
 
-        @property
-        def currenttns(self):
+        def _cleanup_tns_file(self):
             tns = self.vfs.tryread(b'topic-namespace')
-            # we should definitely drop this at some point, but it depends on
-            # our own release schedule, not core's, so here's hg 1.0
-            # hg <= 1.0 (cfa08c88a5c4)
             if tns == b'none':
                 try:
                     with self.wlock(wait=False):
@@ -735,11 +731,14 @@
                     # if we cannot acquire wdir lock, then we shouldn't do
                     # anything at all, since it'd be unsafe to modify wdir
                     pass
-            elif tns == b'':
-                # technically, if user creates an empty file, it should be
-                # handled differently than non-existing file, but the
-                # distinction is probably not that important
-                tns = b'none'
+
+        @property
+        def currenttns(self):
+            # we should definitely drop this at some point, but it depends on
+            # our own release schedule, not core's, so here's hg 1.0
+            # hg <= 1.0 (cfa08c88a5c4)
+            self._cleanup_tns_file()
+            tns = self.vfs.tryread(b'topic-namespace') or b'none'
             return encoding.tolocal(tns)
 
         @util.propertycache