Benoît Allard committed bc3a673

Add filtering at the file level through the configuration file

  • Participants
  • Parent commits 28a42fd

Comments (0)

Files changed (2)

+Filtering of changesets
 The value of the regex to filter issue changesets can be configured in
 the mercurial configuration file. In this case, if not provided on the
 command line, this one will be taken. The value is configured as
 provided, all non-merge changesets will be considered in the
+Filtering of files
+To filter some parts of the files out of the computation, like the
+``docs`` or the ``test`` directory for instance, a set of exclude and
+include rules can be used like in the following example::
+    [hotfiles]
+    exclude.glob =
+      mercurial/
+    include.glob =
+      mercurial/
+If the ``include.glob`` key is not set, all files will be included, if
+the ``exclude.glob`` key is not set, all included files will be
 from mercurial import cmdutil, scmutil
 from mercurial.i18n import _
 from mercurial.node import nullrev
+from mercurial.match import match
 cmdtable = {}
     ui.debug('using %s as pattern to filter changesets' % pattern)
     r = re.compile(pattern)
+    excludeglob = ui.configlist('hotfiles', 'exclude.glob', [])
+    includeglob = ui.configlist('hotfiles', 'include.glob', [])
+    m = match(repo.root, '', None, exclude=excludeglob, include=includeglob)
     if not node:
         node = rev
     data = {}
     for f in ctx:
-        data[f] = []
+        if m(f):
+            data[f] = []
     rev = ctx.rev()