7
Bazaar's content filtering allows you to store files in a different
8
format from the copy in your working tree. This lets you, or your
9
co-developers, use Windows development tools that expect CRLF files
10
on projects that use other line-ending conventions. Among other things,
11
content filters also let Unix developers more easily work on projects
12
using Windows line-ending conventions, keyword expansion/compression,
13
and trailing spaces on lines in text files to be implicitly stripped
16
To generalize, there are two content formats supported by Bazaar:
18
* a canonical format - how files are stored internally
19
* a convenience format - how files are created in a working tree.
25
The conversion between these formats is done by content filters.
26
A content filter has two parts:
28
* a read converter - converts from convenience to canonical format
29
* a write converter - converts from canonical to convenience format.
31
Many of these converters will provide *round-trip* conversion,
32
i.e. applying the read converter followed by the write converter
33
gives back the original content. However, others may provide an
34
asymmetric conversion. For example, a read converter might strip
35
trailing whitespace off lines in source code while the matching
36
write converter might pass content through unchanged.
39
Enabling content filters
40
------------------------
42
Content filters are typically provided by plugins, so the first step
43
in using them is to install the relevant plugins and read their
44
documentation. Some plugins may be very specific about which files
45
they filter, e.g. only files ending in ``.java`` or ``.php``.
46
In other cases, the plugin may leave it in the user's hands to
47
define which files are to be filtered. This is typically done
48
using rule-based preferences. See ``bzr help rules`` for general
49
information about defining these.
55
Read converters are only applied to commands that read content from
56
a working tree, e.g. status, diff and commit. For example, ``bzr diff``
57
will apply read converters to files in the working tree, then compare
58
the results to the content last committed.
60
Write converters are only applied by commands that **create files in a
61
working tree**, e.g. branch, checkout, update. If you wish to see the
62
canonical format of a file or tree, use ``bzr cat`` or ``bzr export``
65
Note: ``bzr commit`` does not implicitly apply write converters after
66
comitting files. If this makes sense for a given plugin providing
67
a content filter, the plugin can usually achieve this effect by using a
68
``start_commit`` or ``post_commit`` hook say. See :doc:`hooks-help`
69
for more information on hooks.
72
Refreshing your working tree
73
----------------------------
75
For performance reasons, Bazaar caches the timestamps of files in
76
a working tree, and assumes files are unchanged if their timestamps
77
match the cached values. As a consequence, there are times when
78
you may need to explicitly ask for content filtering to be reapplied
79
in one or both directions, e.g. after installing or reconfiguring
82
Here are some general guidelines for doing this:
84
* To reapply read converters, ``touch`` files, i.e. update their
85
timestamp. Operations like ``bzr status`` should then reapply the
86
relevant read converters and compare the end result with the
89
* To reapply write converters, ensure there are no local changes,
90
delete the relevant files and run ``bzr revert`` on those files.
92
Note: In the future, it is likely that additional options will be added
93
to commands to make this refreshing process faster and safer.