Mercurial > hg
comparison hgext/fsmonitor/__init__.py @ 41489:5125f0a9728b
watchman: detect nested mercurial repositories and abort
Disable fsmonitor on nested mercurial repositories. Only depth one
repositories are detected at the moment.
Differential Revision: https://phab.mercurial-scm.org/D5587
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 21 Dec 2018 17:10:07 +0100 |
parents | 18adb747a332 |
children | 286eeed14893 |
comparison
equal
deleted
inserted
replaced
41488:18adb747a332 | 41489:5125f0a9728b |
---|---|
365 foldmap[normed] = fname | 365 foldmap[normed] = fname |
366 fmode = entry['mode'] | 366 fmode = entry['mode'] |
367 fexists = entry['exists'] | 367 fexists = entry['exists'] |
368 kind = getkind(fmode) | 368 kind = getkind(fmode) |
369 | 369 |
370 if '/.hg/' in fname or fname.endswith('/.hg'): | |
371 return bail('nested-repo-detected') | |
372 | |
370 if not fexists: | 373 if not fexists: |
371 # if marked as deleted and we don't already have a change | 374 # if marked as deleted and we don't already have a change |
372 # record, mark it as deleted. If we already have an entry | 375 # record, mark it as deleted. If we already have an entry |
373 # for fname then it was either part of walkexplicit or was | 376 # for fname then it was either part of walkexplicit or was |
374 # an earlier result that was a case change | 377 # an earlier result that was a case change |
738 distance=distance, partial=partial): | 741 distance=distance, partial=partial): |
739 return orig( | 742 return orig( |
740 repo, node, branchmerge, force, ancestor, mergeancestor, | 743 repo, node, branchmerge, force, ancestor, mergeancestor, |
741 labels, matcher, **kwargs) | 744 labels, matcher, **kwargs) |
742 | 745 |
746 def repo_has_depth_one_nested_repo(repo): | |
747 for f in repo.wvfs.listdir(): | |
748 if os.path.isdir(os.path.join(repo.root, f, '.hg')): | |
749 msg = 'fsmonitor: sub-repository %r detected, fsmonitor disabled\n' | |
750 repo.ui.debug(msg % f) | |
751 return True | |
752 return False | |
753 | |
743 def reposetup(ui, repo): | 754 def reposetup(ui, repo): |
744 # We don't work with largefiles or inotify | 755 # We don't work with largefiles or inotify |
745 exts = extensions.enabled() | 756 exts = extensions.enabled() |
746 for ext in _blacklist: | 757 for ext in _blacklist: |
747 if ext in exts: | 758 if ext in exts: |
753 # We don't work with subrepos either. | 764 # We don't work with subrepos either. |
754 # | 765 # |
755 # if repo[None].substate can cause a dirstate parse, which is too | 766 # if repo[None].substate can cause a dirstate parse, which is too |
756 # slow. Instead, look for a file called hgsubstate, | 767 # slow. Instead, look for a file called hgsubstate, |
757 if repo.wvfs.exists('.hgsubstate') or repo.wvfs.exists('.hgsub'): | 768 if repo.wvfs.exists('.hgsubstate') or repo.wvfs.exists('.hgsub'): |
769 return | |
770 | |
771 if repo_has_depth_one_nested_repo(repo): | |
758 return | 772 return |
759 | 773 |
760 fsmonitorstate = state.state(repo) | 774 fsmonitorstate = state.state(repo) |
761 if fsmonitorstate.mode == 'off': | 775 if fsmonitorstate.mode == 'off': |
762 return | 776 return |