[PATCH 1 of 5] ignore: move .hgignore parsing in a function
Patrick Mezard
pmezard at gmail.com
Sat Sep 15 14:29:49 CDT 2007
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1189881959 -7200
# Node ID 3f5c1f4a9ac4135e1e81a71ee9aff485927f6e9d
# Parent ba3dc78839686ccb285f4227a80356f7b13e6f8f
ignore: move .hgignore parsing in a function
diff --git a/mercurial/ignore.py b/mercurial/ignore.py
--- a/mercurial/ignore.py
+++ b/mercurial/ignore.py
@@ -21,26 +21,7 @@ def _parselines(fp):
if line:
yield line
-def ignore(root, files, warn):
- '''return the contents of .hgignore files as a list of patterns.
-
- the files parsed for patterns include:
- .hgignore in the repository root
- any additional files specified in the [ui] section of ~/.hgrc
-
- trailing white space is dropped.
- the escape character is backslash.
- comments start with #.
- empty lines are skipped.
-
- lines can be of the following formats:
-
- syntax: regexp # defaults following lines to non-rooted regexps
- syntax: glob # defaults following lines to non-rooted globs
- re:pattern # non-rooted regular expression
- glob:pattern # non-rooted glob
- pattern # pattern of the current default type'''
-
+def _parsefiles(files, warn):
syntaxes = {'re': 'relre:', 'regexp': 'relre:', 'glob': 'relglob:'}
pats = {}
for f in files:
@@ -69,6 +50,29 @@ def ignore(root, files, warn):
if f != files[0]:
warn(_("skipping unreadable ignore file '%s': %s\n") %
(f, inst.strerror))
+ return pats
+
+def ignore(root, files, warn):
+ '''return the contents of .hgignore files as a list of patterns.
+
+ the files parsed for patterns include:
+ .hgignore in the repository root
+ any additional files specified in the [ui] section of ~/.hgrc
+
+ trailing white space is dropped.
+ the escape character is backslash.
+ comments start with #.
+ empty lines are skipped.
+
+ lines can be of the following formats:
+
+ syntax: regexp # defaults following lines to non-rooted regexps
+ syntax: glob # defaults following lines to non-rooted globs
+ re:pattern # non-rooted regular expression
+ glob:pattern # non-rooted glob
+ pattern # pattern of the current default type'''
+
+ pats = _parsefiles(files, warn)
allpats = []
[allpats.extend(patlist) for patlist in pats.values()]
More information about the Mercurial-devel
mailing list