This prepares the source code for the changes discussed in issue #24.
Note that this is just a quick restructuring in order to see the resulting
classes and separation. More work will be done to make it more elegant
and with less dependencies between modules.
When filtering, "git show" is called in order to pull the commit message
from the git log. While slow, it makes certain that the message itself is
pulled correctly, including any escape characters that might be present.
Specific commits can now be filtered by using;
-x, --exclude="revision:<SHA-1>"
Like with all other filtering in gitinspector, regular expressions are
supported. Likewise, multiple revisions can be specified using a comma or
by simply supplying multiple exclude parameters.
As usual, both the commit module and blame module take this filtering into
account.
Instead of specifying -x (or --exclude) multiple times, it is possible to
specify multiple filtering rules by separating each rule with a comma (,)
character. This enables the new support for filtering authors and email to
work in conjunction with git-config.
As a side effect, this means that we reserve the comma character for
internal use in gitinspector and that it can't be used in any regular
expression or filtering rule. However, this is not a big problem.
Of course, specifying -x multiple times (like before) is still supported.
To access this functionality; the -x flag can now be called in the
following ways:
-x file
-x file:<file>
-x author:<author name>
-x email:<email>
Just passing -x file will presume that the filtering rule is intended for
a file (just like the previous behavior).
All the filtering is case sensitive (even filtering by email) in order to
not break any regular expressions used. Case-insensitive matching can
instead be easily achieved with the appropriate regular expression.
To get reversed filtering (excluding everything not matched within -x) a
regular expression with the a syntax such as '^(?!<rule>)' can be used.
This is a better solution than simply relying on ValueError and also
helps us to maintain compatibility with all our other exceptions (it gives
us a msg attribute that we can access when catching the error).
Also localized the string for InvalidRegExpError.
In the process, the new strings were also translated to Swedish. To
properly handle localized string constants, a new function "N_()" was
added which can be supplied to xgettext when collecting strings.
The default behaviour is now not to localize the output, only the help
text and error messages (all the user interaction).
The way localized messages are fetched in the modules has been modified
as well; to allow for the ability to enable and disable the localization.
The gettext.install() functions supplies a way to force it to return
unicode which helps with compatibility between Python 2 & 3. To make it
work properly when merging those returned string with strings in the
different modules of gitinspector we also had to do some changes to make
sure all string literals are in unicode.