gitignore: add a config option

Summary:
gitignore could have performance issues stating .gitignore files everywhere.
That happens if watchman returns O(working copy) files. Add a config to
disable it as we're finding solutions.

Reviewed By: DurhamG

Differential Revision: D7482499

fbshipit-source-id: 4c9247b0318bf034c8e9af4b74c21110cc598714
This commit is contained in:
Jun Wu 2018-04-02 23:21:53 -07:00 committed by Saurabh Singh
parent 1b393dbae1
commit d0886b9b94
5 changed files with 19 additions and 3 deletions

View File

@ -998,6 +998,9 @@ coreconfigitem('ui', 'formatjson',
coreconfigitem('ui', 'formatted',
default=None,
)
coreconfigitem('ui', 'gitignore',
default=False,
)
coreconfigitem('ui', 'graphnodetemplate',
default=None,
)

View File

@ -164,7 +164,10 @@ class dirstate(object):
@rootcache('.hgignore')
def _ignore(self):
files = self._ignorefiles()
gitignore = matchmod.gitignorematcher(self._root, '')
if self._ui.configbool('ui', 'gitignore'):
gitignore = matchmod.gitignorematcher(self._root, '')
else:
gitignore = matchmod.nevermatcher(self._root, '')
if not files:
return gitignore

View File

@ -2084,6 +2084,9 @@ User interface controls.
Encoding to try if it's not possible to decode the changelog using
UTF-8. (default: ISO-8859-1)
``gitignore``
Respect gitignore or not. (default: False)
``graphnodetemplate``
The template used to print changeset nodes in an ASCII revision graph.
(default: ``{graphnode}``)

View File

@ -1,4 +1,5 @@
$ newrepo
$ setconfig ui.gitignore=1
$ cat > .gitignore << EOF
> *.tmp

View File

@ -3,9 +3,12 @@
gitignore is used when there is no hgignore:
$ hg debugignore
$ hg debugignore --config ui.gitignore=1
<gitignorematcher>
$ hg debugignore --config ui.gitignore=0
<nevermatcher>
Issue562: .hgignore requires newline at end:
$ touch foo
@ -197,9 +200,12 @@ Test relative ignore path (issue4473):
$ hg status .
A b.o
$ hg debugignore
$ hg debugignore --config ui.gitignore=1
<unionmatcher matchers=[<gitignorematcher>, <includematcher includes='(?:(?:|.*/)[^/]*(?:/|$))'>]>
$ hg debugignore
<unionmatcher matchers=[<nevermatcher>, <includematcher includes='(?:(?:|.*/)[^/]*(?:/|$))'>]>
$ hg debugignore b.o
b.o is ignored
(ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob)