Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 6657:1c998ed77597 stable
topic: remove .hg/topic-namespace file if it has the default value
See the comment in the test file for the rationale behind this patch.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 19 Jan 2024 14:29:35 -0300 |
parents | d3668c704d40 |
children | 991d78f5c401 |
comparison
equal
deleted
inserted
replaced
6656:d3668c704d40 | 6657:1c998ed77597 |
---|---|
155 | branch: my-branch | 155 | branch: my-branch |
156 """ | 156 """ |
157 | 157 |
158 from __future__ import absolute_import | 158 from __future__ import absolute_import |
159 | 159 |
160 import errno | |
160 import functools | 161 import functools |
161 import re | 162 import re |
162 import time | 163 import time |
163 import weakref | 164 import weakref |
164 | 165 |
714 self._topic_namespaces = namespaces | 715 self._topic_namespaces = namespaces |
715 return namespaces | 716 return namespaces |
716 | 717 |
717 @property | 718 @property |
718 def currenttns(self): | 719 def currenttns(self): |
719 tns = self.vfs.tryread(b'topic-namespace') or b'none' | 720 tns = self.vfs.tryread(b'topic-namespace') |
721 # we should definitely drop this at some point, but it depends on | |
722 # our own release schedule, not core's, so here's hg 1.0 | |
723 # hg <= 1.0 (cfa08c88a5c4) | |
724 if tns == b'none': | |
725 try: | |
726 with self.wlock(wait=False): | |
727 try: | |
728 # we make sure the file contains what we expect | |
729 if self.vfs.read(b'topic-namespace') == b'none': | |
730 repo.vfs.unlinkpath(b'topic-namespace') | |
731 except IOError as err: | |
732 if err.errno != errno.ENOENT: | |
733 raise | |
734 except error.LockError: | |
735 # if we cannot acquire wdir lock, then we shouldn't do | |
736 # anything at all, since it'd be unsafe to modify wdir | |
737 pass | |
738 elif tns == b'': | |
739 # technically, if user creates an empty file, it should be | |
740 # handled differently than non-existing file, but the | |
741 # distinction is probably not that important | |
742 tns = b'none' | |
720 return encoding.tolocal(tns) | 743 return encoding.tolocal(tns) |
721 | 744 |
722 @util.propertycache | 745 @util.propertycache |
723 def _topiccache(self): | 746 def _topiccache(self): |
724 return {} | 747 return {} |