Patchwork D5587: watchman: detect nested mercurial repositories and abort

login
register
mail settings
Submitter phabricator
Date Jan. 24, 2019, 5:40 p.m.
Message ID <1934fb02cfec6d0692e0bb3ae12039b8@localhost.localdomain>
Download mbox | patch
Permalink /patch/37984/
State Not Applicable
Headers show

Comments

phabricator - Jan. 24, 2019, 5:40 p.m.
lothiraldan updated this revision to Diff 13412.
Herald added a subscriber: mjpieters.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5587?vs=13223&id=13412

REVISION DETAIL
  https://phab.mercurial-scm.org/D5587

AFFECTED FILES
  hgext/fsmonitor/__init__.py

CHANGE DETAILS




To: lothiraldan, #hg-reviewers, indygreg
Cc: mjpieters, indygreg, mercurial-devel

Patch

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -385,6 +385,9 @@ 
         fexists = entry['exists']
         kind = getkind(fmode)
 
+        if '/.hg/' in fname or fname.endswith('/.hg'):
+            return bail('nested-repo-detected')
+
         if not fexists:
             # if marked as deleted and we don't already have a change
             # record, mark it as deleted.  If we already have an entry
@@ -758,6 +761,14 @@ 
             repo, node, branchmerge, force, ancestor, mergeancestor,
             labels, matcher, **kwargs)
 
+def repo_has_depth_one_nested_repo(repo):
+    for f in repo.wvfs.listdir():
+        if os.path.isdir(os.path.join(repo.root, f, '.hg')):
+            msg = 'fsmonitor: sub-repository %r detected, fsmonitor disabled\n'
+            repo.ui.debug(msg % f)
+            return True
+    return False
+
 def reposetup(ui, repo):
     # We don't work with largefiles or inotify
     exts = extensions.enabled()
@@ -775,6 +786,9 @@ 
         if repo.wvfs.exists('.hgsubstate') or repo.wvfs.exists('.hgsub'):
             return
 
+        if repo_has_depth_one_nested_repo(repo):
+            return
+
         fsmonitorstate = state.state(repo)
         if fsmonitorstate.mode == 'off':
             return