This page last changed on Jun 09, 2005 by orogers.

What is FilteredSourceControl?

The FilteredSourceControl allows you to filter out modifications that are used to trigger a build. If for example, you have certain files (such as web pages or document files) under source control that you don't want to have trigger the build, you can use this class to ensure that their changes will keep a new build from launching.

The FilteredSourceControl works together with all of the source controls supported by CCNet (including the Multi Source Control Block). It can also be included under the Multi Source Control Block provider so that you could have multiple FilterSourceControls each filtering a different set of modifications from different source control providers. Essentially, it acts as a decorator (or an example of the pipes and filters pattern ), wrapping around the specific SourceControl provider that you want to use.

The FilteredSourceControl includes both inclusion and exclusion filters for specifying what modifications should be included/excluded. Multiple inclusion and exclusion filters can be specified or, alternately, no inclusion or exclusion filter could be specified. If a modification is matched by both the inclusion and exclusion filter, then the exclusion filter will take preference and the modification will not be included in the modification set. At this point, CCNet only supports two types of filters: PathFilters and UserFilters. It is relatively straightforward to build new filters, (such as one to filter modifications based on email address).

Configuration Examples

<sourcecontrol type="filtered">
    <sourceControlProvider type="vss" autoGetSource="true">
      <project>$/Kunigunda/ServiceLocator</project>
      <workingDirectory>C:\CCNet\Kunigunda\ServiceLocator</workingDirectory>
      <username>urosn</username>
      <password></password>
      <ssdir>c:\localvss</ssdir>
    </sourceControlProvider>
    <inclusionFilters>
      <pathFilter>
      	<pattern>$/Kunigunda/ServiceLocator/Sources/**/*.*</pattern>
      </pathFilter>
    </inclusionFilters>
    <exclusionFilters>
    	<pathFilter>
    		<pattern>$/Kunigunda/ServiceLocator/Sources/Kunigunda.ServiceLocator/AssemblyInfo.cs</pattern>
    	</pathFilter>
	<pathFilter>
		<pattern>$/**/*.vssscc</pattern>
	</pathFilter>
	<userFilter>
		<names><name>Perry</name><name>Joe</name></names>
	</userFilter>
    </exclusionFilters>
</sourcecontrol>

This example filters out any modifications to the AssemblyInfo.cs file that have been checked in to Visual Source Safe Source Control Block.

Configuration Elements:

FilteredSourceControl root element

This is the root configuration element for the FilteredSourceControl.
Node Description Type Required
sourceControlProvider This element is used to specify the type of source control provider to retrieve modifications from. With the exception of the element name, the configuration for this element is identical to the xml configuration for the specific source control provider you intend to use. xml element true
inclusionFilters Specifies the filters that should be used to determine which modifications should be included. This element should contain the xml configuration for one or more filters. xml element false
exclusionFilters Specifies the filters that should be used to determine which modifications should be excluded. This element should contain the xml configuration for one or more filters. xml element false

 PathFilter element

The PathFilter can be used to filter modifications on the basis of their file path.

Node Description Type Required
pattern This is the pattern used to compare the modification path against. See below for examples of the syntax for this element. Each PathFilter contains a single pattern element. string true

 UserFilter element

The UserFilter can be used to filter modifications on the basis of the username that committed the changes.

Node Description Type Required
names This element consists of multiple <name> elements for each username to be filtered. string true

Using the PathFilter:

PathFilter supports following wildcards:

  1. "*" used as part of the path will match none or exactly one subfolder. E.g. pattern "/Kunigunda/*/Sources/*.*" will accept "/Kunigunda/Sources/*.*", "/Kunigunda/Service/Sources/*.*", "/Kunigunda/Web/Sources/*.*", etc.
  2. "*" used as part of the folder name will match zero or more characters that can appear in the folder name. E.g. pattern "/Kunigunda/Sources/Test*/*.*" will accept "/Kunigunda/Sources/Test/*.*", "/Kunigunda/Sources/Tests/*.*", etc.
  3. "*" used as part of the filename will match zero or more characters that can appear in the file name. E.g. pattern
    "/Kunigunda/Sources/*.cs" will accept all files in the "/Kunigunda/Sources" folder with the ".cs" extension. If the "*" is prefixed, postfixed or wrapped with one or more characters, then these will be included in the pattern matching. E.g. pattern "/Kunigunda/Sources/*Test.cs", will
    accept all files in the "/Kunigunda/Sources/" folder that have "Test" and the end of the name and the ".cs" extension.
  4. "*" used as part of the extension will match zero or more characters that can appear in the extension. E.g. pattern "/Kunigunda/Sources/Build.*" will match all files in "/Kunigunda/Sources" folder named "Build" regardles of their extension. A "*.*" pattern will match any file name and
    extension. A "*.cs*" will match any file with extension that starts with "cs".
  5. "**" used as part of the path will match zero or more subfolders. E.g. pattern "/Kunigunda/Sources/**/Test/*.*" will accept all files stored in "Test" subfolder anywhere bellow the "/Kunigunda/Sources" tree including "/Kunigunda/Sources/Test/*.*", "/Kunigunda/Sources/Core/Test/*.*".

Potential enhancements:

  1. Case insensitive pattern matching.
  2. Support for "?" as a wildcard in patterns.
  3. Current patterns are only an approximation of the pattersn used in NAnt filesets. Pattern translation and evaluation types in NAnt assembly are not public so it is not possible to use them directly but it would be a nice optimization.

Implemented and contributed by Uros Novak.
UserFilter by Perry Ismangil
Document generated by Confluence on Jun 26, 2005 17:22