ignore: clean up legacy hgignore related code

Summary:
".hgignore" is long deprecated in favor of ".gitignore". Let's clean up the code.

This diff has a minor output change for "debugignore" where non-ignored files in sparse repo now have output consistent with non-sparse repos (i.e. "{file}: not ignored" instead of "{file} is not ignored").

Reviewed By: quark-zju

Differential Revision: D52494274

fbshipit-source-id: 6191a24f008c1b326ae439b87b6b61f8f6fd11da
This commit is contained in:
Muir Manders 2024-01-09 14:45:21 -08:00 committed by Facebook GitHub Bot
parent ac0187acb2
commit de4e481d8f
12 changed files with 8 additions and 81 deletions

View File

@ -357,7 +357,7 @@ _hg_clone_dest() {
}
_hg_add_help_topics=(
config dates diffs environment extensions filesets glossary hgignore
config dates diffs environment extensions filesets glossary
merge-tools multirevs obsolescence patterns phases revisions revsets
subrepos templating urls
)

View File

@ -166,9 +166,7 @@ def showtopic(ui, topic):
(["common"], "", loaddoc("common")),
(["hg.1"], "", loaddoc("hg.1")),
(["hg-ssh.8"], "", loaddoc("hg-ssh.8")),
(["hgignore.5"], "", loaddoc("hgignore.5")),
(["hgrc.5"], "", loaddoc("hgrc.5")),
(["hgignore.5.gendoc"], "", loaddoc("hgignore")),
(["hgrc.5.gendoc"], "", loaddoc("config")),
]
helpprinter(ui, helptable + extrahelptable, None, include=[topic])

View File

@ -105,7 +105,6 @@ bundle2-exp=True
changegroup3=True
copytrace=off
crecord=True
disallowhgignorefileset=True
evolution=obsolete
fsmonitor.transaction_notify=True
graphstyle.grandparent=|

View File

@ -1502,39 +1502,9 @@ def debugignore(ui, repo, *files, **opts) -> None:
# Show all the patterns
ui.write("%s\n" % repr(ignore))
else:
explain = getattr(ignore, "explain", None)
# The below code can be removed after hgignore is removed.
visitdir = ignore.visitdir
m = scmutil.match(repo[None], pats=files)
for f in m.files():
# The matcher supports "explain", use it.
if explain:
explanation = explain(f)
if explanation:
ui.write(_x("%s\n") % explain(f))
continue
nf = util.normpath(f)
ignored = None
if nf != ".":
if ignore(nf):
ignored = nf
else:
for p in util.finddirs(nf):
if visitdir(p) == "all":
ignored = p
break
if ignored:
if ignored == nf:
ui.write(_("%s is ignored\n") % m.uipath(f))
else:
ui.write(
_("%s is ignored because of containing folder %s\n")
% (m.uipath(f), ignored)
)
else:
ui.write(_("%s is not ignored\n") % m.uipath(f))
ui.write(_x("%s\n") % ignore.explain(f))
@command(
@ -1550,12 +1520,6 @@ def debugindex(ui, repo, file_=None, **opts) -> None:
if format not in (0, 1):
raise error.Abort(_("unknown format %d") % format)
generaldelta = r.version & revlog.FLAG_GENERALDELTA
if generaldelta:
basehdr = " delta"
else:
basehdr = " base"
if ui.debugflag:
shortfn = hex
else:
@ -1580,10 +1544,6 @@ def debugindex(ui, repo, file_=None, **opts) -> None:
for i in r:
node = r.node(i)
if generaldelta:
base = r.deltaparent(i)
else:
base = r.chainbase(i)
if format == 0:
try:
pp = r.parents(node)

View File

@ -457,7 +457,6 @@ coreconfigitem("ui", "formatted", default=None)
coreconfigitem("ui", "git", default="git")
coreconfigitem("ui", "gitignore", default=True)
coreconfigitem("ui", "graphnodetemplate", default=None)
coreconfigitem("ui", "hgignore", default=False)
coreconfigitem("ui", "http2debuglevel", default=None)
coreconfigitem("ui", "ignorerevnum", default=True)
coreconfigitem("ui", "interactive", default=None)

View File

@ -157,7 +157,7 @@ If set, wait for watchman to complete a full crawl before performing queries.
# * fsmonitor will disable itself if any of the following extensions are
# enabled: largefiles, inotify, eol.
# * fsmonitor will produce incorrect results if nested repos exist.
# *Workaround*: add nested repo paths to your `.hgignore`.
# *Workaround*: add nested repo paths to your `.gitignore`.
#
# The issues related to nested repos are probably not fundamental
# ones. Patches to fix them are welcome.

View File

@ -3194,15 +3194,11 @@ class ignorematcher(unionmatcher):
super().__init__([origignorematcher, negativesparsematcher])
def explain(self, f):
if self._origignore(f):
explain = getattr(self._origignore, "explain", None)
if explain:
return explain(f)
elif self._negativesparse(f):
if self._origignore(f) or not self._negativesparse(f):
return self._origignore.explain(f)
else:
return "%s is not in sparse profile" % f
return None
class negatematcher(matchmod.basematcher):
def __init__(self, matcher):

View File

@ -317,19 +317,6 @@ def unresolved(mctx, x):
return [f for f in mctx.subset if f in ms and ms[f] == "u"]
@predicate("hgignore()")
def hgignore(mctx, x):
"""File that matches the active .hgignore pattern. (DEPRECATED)"""
# i18n: "hgignore" is a keyword
getargs(x, 0, 0, _("hgignore takes no arguments"))
repo = mctx.ctx.repo()
ui = repo.ui
if ui.configbool("experimental", "disallowhgignorefileset"):
raise error.Abort(_("hgignore() is deprecated. Use gitignore() instead."))
ignore = repo.dirstate._ignore
return mctx.matches(ignore)
@predicate("gitignore()")
def gitignore(mctx, x):
"""File that matches the active .gitignore pattern."""

View File

@ -2342,10 +2342,6 @@ User interface controls.
The template used to print changeset nodes in an ASCII revision graph.
(default: ``{graphnode}``)
``hgignore``
The hgignore feature is being deprecated. Use .gitignore instead.
Respect ``.hgignore`` at the root of a repo. (default: False)
``ignore``
A file to read per-user ignore patterns from. This file should be
in the same format as a repository-wide .gitignore file. Filenames

View File

@ -12,14 +12,6 @@ from .i18n import _
hinttable = {
"hgignore-deprecate": lambda path: (
(
"hgignore format is being deprecated. "
"Consider updating %s to gitignore format. "
"Check fburl.com/gitignore to learn more."
)
% path
),
"branch-command-deprecate": lambda: _(
"'@prog@ branch' command does not do what you want, and is being removed. "
"It always prints 'default' for now. "

View File

@ -65,6 +65,6 @@ Works with sparse checkouts as well.
a: ignored by rule a from .gitignore
$ hg debugignore b
b is not ignored
b: not ignored
$ hg debugignore c
c is not in sparse profile

View File

@ -7,7 +7,7 @@
$ eagerepo
$ newrepo
$ setconfig 'ui.gitignore=1' 'ui.hgignore=0'
$ setconfig 'ui.gitignore=1'
$ cat > .gitignore << 'EOF'
> *.tmp