changeset 6735:5b08e93a982e stable

topic: run _cleanup_tns_file() when acquiring fresh wlock
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 28 Feb 2024 15:23:39 -0300
parents c2a4e21f4aaf
children ce3723b78f91
files hgext3rd/topic/__init__.py
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Wed Feb 28 15:07:52 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Wed Feb 28 15:23:39 2024 -0300
@@ -715,11 +715,20 @@
             self._topic_namespaces = namespaces
             return namespaces
 
+        def wlock(self, wait=True):
+            lock = super(topicrepo, self).wlock(wait=wait)
+            # 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 lock is not None and lock.held:
+                self._cleanup_tns_file()
+            return lock
+
         def _cleanup_tns_file(self):
             tns = self.vfs.tryread(b'topic-namespace')
             if tns == b'none':
                 try:
-                    with self.wlock(wait=False):
+                    with super(topicrepo, self).wlock(wait=False):
                         try:
                             # we make sure the file contains what we expect
                             if self.vfs.read(b'topic-namespace') == b'none':
@@ -734,10 +743,6 @@
 
         @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)