r1466570 | stsp | 2013-04-10 17:08:31 +0000 (Wed, 10 Apr 2013)
Add support for custom keyword definitions, fixing issue #890.
Custom keywords can be defined using a format string which controls
the way keyword information is expanded. For instance, a keyword set
the command 'svn propset svn:keywords MyKeyword=%a%_%b%_%d myfile'
can be referenced in 'myfile' as $MyKeyword$, and expands to the author,
a space, the file's name ('myfile'), another space, and the short
representation of the date of the last-changed revision.
The following format codes are currently available:
%a - The author.
%b - The basename of the URL.
%d - Short format of the date.
%D - Long format of the date.
%P - The file's path, relative to the repository root URL.
%r - The revision.
%R - The URL to the root of the repository.
%u - The URL of the file.
%_ - A space (keyword definitions cannot contain a literal space).
%% - A literal '%'.
Most of these were already defined internally in libsvn_subr.
This patch adds the %P, %R, and %_ format codes.
More format codes could be added in the future but might require API changes.
Based on a patch submitted several times by various FreeBSD developers
who have added this feature to their port of Subversion.
I'm crediting those who I know were involved in this patch in one way
or another. But I don't know for sure who wrote the initial implementation.
Patch by: Peter Wemm <peter{_AT_}FreeBSD.org>
David O'Brien <obrien{_AT_}FreeBSD.org>
Lev A. Serebryakov <lev{_AT_}FreeBSD.org>
Alfred Perlstein <alfred{_AT_}FreeBSD.org>
me
* subversion/include/svn_subst.h
(svn_subst_build_keywords3): Declare.
(svn_subst_build_keywords2): Deprecate.
* subversion/libsvn_client/cat.c
(svn_client__get_normalized_stream): Call svn_subst_build_keywords3().
* subversion/libsvn_client/export.c
(export_node, close_file): Call svn_subst_build_keywords3().
* subversion/libsvn_client/import.c
(send_file_contents): Call svn_subst_build_keywords3().
* subversion/libsvn_subr/subst.c
(keyword_printf): Add support for %P, %R, and %_. Add repos_root_url
parameter which is required to implement these new format codes.
(build_keywords): New helper function which implements the guts of
svn_subst_build_keywords2() and svn_subst_build_keywords3().
(svn_subst_build_keywords2): Reimplement as wrapper around build_keywords().
Turn off support for custom keywords to ensure backwards compatibility.
(svn_subst_build_keywords3): New, implemented as wrapper around the
build_keywords() helper. Enable support for custom keywords.
* subversion/libsvn_wc/translate.c
(svn_wc__expand_keywords): Call svn_subst_build_keywords3().
* subversion/svn/svn.c
(svn_cl__cmd_table): Document the custom keywords feature, including the
support format codes, in the output of 'svn help propset'.
* subversion/tests/libsvn_subr/subst_translate-test.c
(test_svn_subst_build_keywords3): New test.
(test_funcs): Add new test.