# HG changeset patch # User Anton Shestakov # Date 1709144619 10800 # Node ID 5b08e93a982e860c1c6df478aae66f053e415e19 # Parent c2a4e21f4aaf2456d1f09ea7a856610fb7e01ac2 topic: run _cleanup_tns_file() when acquiring fresh wlock diff -r c2a4e21f4aaf -r 5b08e93a982e hgext3rd/topic/__init__.py --- 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)