changeset 6736:ce3723b78f91 stable

topic: drop _cleanup_tns_file(), move code directly into wlock() This way we don't even have to make any assertions about wlock status. This should be safe, since we have the wlock and it's held, and other processes cannot acquire it and start messing with wdir, but we're also not inside any context managers that could be using the wlock, so it cannot be suddenly released either.
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 11 Mar 2024 16:35:29 -0300
parents 5b08e93a982e
children 08a9113a15ee
files hgext3rd/topic/__init__.py
diffstat 1 files changed, 6 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Wed Feb 28 15:23:39 2024 -0300
+++ b/hgext3rd/topic/__init__.py	Mon Mar 11 16:35:29 2024 -0300
@@ -721,26 +721,14 @@
             # 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()
+                try:
+                    if self.vfs.read(b'topic-namespace') == b'none':
+                        repo.vfs.unlinkpath(b'topic-namespace')
+                except IOError as err:
+                    if err.errno != errno.ENOENT:
+                        raise
             return lock
 
-        def _cleanup_tns_file(self):
-            tns = self.vfs.tryread(b'topic-namespace')
-            if tns == b'none':
-                try:
-                    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':
-                                repo.vfs.unlinkpath(b'topic-namespace')
-                        except IOError as err:
-                            if err.errno != errno.ENOENT:
-                                raise
-                except error.LockError:
-                    # if we cannot acquire wdir lock, then we shouldn't do
-                    # anything at all, since it'd be unsafe to modify wdir
-                    pass
-
         @property
         def currenttns(self):
             tns = self.vfs.tryread(b'topic-namespace') or b'none'