You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Kimitake <ki...@gmail.com> on 2008/10/20 13:25:48 UTC

[PATCH] issue #890: Implementation of Custom keywords

Hi subversion developers,

I just modified subst.c to support redefine keyword feature like GNU CVS.
To use this, add the following to property.

NetBSD=Id

This example is for NetBSD project, so $NetBSD$ keyword is replaced like
$Id$ one.

I have submitted this before, but recreated it with trunk.

Regards,
Kimitake

Index: subversion/libsvn_subr/subst.c
===================================================================
--- subversion/libsvn_subr/subst.c      (revision 33771)
+++ subversion/libsvn_subr/subst.c      (working copy)
@@ -396,7 +396,17 @@
   for (i = 0; i < keyword_tokens->nelts; ++i)
     {
       const char *keyword = APR_ARRAY_IDX(keyword_tokens, i, const char *);
+      const char *replaced_word = keyword;
+      apr_array_header_t *keyword_tokens2;
+      keyword_tokens2 = svn_cstring_split(keyword, "=", TRUE /* chop */,
pool);
+
+      if (keyword_tokens2->nelts==2)
+        {
+          keyword = APR_ARRAY_IDX(keyword_tokens2, 1, const char*);
+          replaced_word = APR_ARRAY_IDX(keyword_tokens2, 0, const char*);
+        }
+
       if ((! strcmp(keyword, SVN_KEYWORD_REVISION_LONG))
           || (! strcmp(keyword, SVN_KEYWORD_REVISION_MEDIUM))
           || (! svn_cstring_casecmp(keyword, SVN_KEYWORD_REVISION_SHORT)))
@@ -450,7 +460,7 @@
           id_val = keyword_printf("%b %r %d %a", rev, url, date, author,
                                   pool);
-          apr_hash_set(*kw, SVN_KEYWORD_ID,
+          apr_hash_set(*kw, replaced_word,
                        APR_HASH_KEY_STRING, id_val);
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] issue #890: Implementation of Custom keywords

Posted by Kimitake <ki...@gmail.com>.
In svn_subst_build_keywords3 method (subst.c) checks
custom keyword and if there is a custom keyword in
the property, the method returns from the loop.
So other keyword won't be checked.

I just deleted it and made sure all keywords were expanded correctly.

I will check http://subversion.tigris.org/hacking.html#patches
and then send a patch.

Regards,
Kimitake

On Tue, Oct 21, 2008 at 12:44 AM, Kimitake <ki...@gmail.com> wrote:
> Hi Stefan,
>
> Thanks for the comment.
>
> I just tried to apply Peter's patch and quick tested it.
> I used %I for replacing Id keyword, and it seems that it works,
> but when I set $Id$ also after %I keyword, $Id$ is not expanded.
>
> e.g. In "NetBSD=%I Id" case, $Id$ is not expanded.
> e.g. In "Id NetBSD=%I" case, $Id$ and $NetBSD$ are expanded properly.
>
> e.g. In NetBSD=%I Rev Date Author Id case, $NetBSD$ only works,
> others are not expanded.
>
> I will look into it and then send a patch later.
>
> Regards,
> Kimitake
>
> On Mon, Oct 20, 2008 at 7:08 AM, Stefan Sperling <st...@elego.de> wrote:
>> On Mon, Oct 20, 2008 at 06:25:48AM -0700, Kimitake wrote:
>>> Hi subversion developers,
>>>
>>> I just modified subst.c to support redefine keyword feature like GNU CVS.
>>> To use this, add the following to property.
>>>
>>> NetBSD=Id
>>>
>>> This example is for NetBSD project, so $NetBSD$ keyword is replaced like
>>> $Id$ one.
>>>
>>> I have submitted this before, but recreated it with trunk.
>>
>> Issue link for those unaware of what's going on:
>> http://subversion.tigris.org/issues/show_bug.cgi?id=890
>>
>> Kimitake, the patch is neat, but it only solves the case where you
>> want to expand $Id$ under a different name.
>>
>> It would be nice to have a more configurable mechanism.
>> Have you seen Peter Wemm's patch at
>> http://people.freebsd.org/~peter/svn_keyword.diff ?
>>
>> Quoting the top of that patch:
>>
>>  # This patch is an extension of patch in issue #860.
>>  # Instead of aliasing one keyword to another, and a big bug (only
>>  # supports aliasing to $Id$ anyway), this version allows
>>  # keyword_printf() format strings.
>>  # svn propset svn:keywords 'Foo=%b Bar=%r' file  (expands $Foo: filename $, etc)
>>  # %I is an alias for $id$-like expansion.  I've added %_ to insert a space.
>>  # eg: 'CustomId=%b%_Some%_Random%_String'.  The svn:keywords parser doesn't
>>  # allow plain spaces.
>>  #
>>  # it adds to keyword_printf():
>>  # %P - $CVSHeader$ like repository-relative paths.
>>  # %_ - a space
>>  # %R - root of repository
>>  # and as aliases in the keyword builder:
>>  # %H - alias for $CVSHeader$ expansion. (%P %r %d %a)
>>  # %I - alias for $Id$ expansion. (%b %r %d %a)
>>  # the keyword builder aliases are because the svn:keyword splitter
>>  # uses spaces.
>>
>> I've asked Peter before whether he could formally submit the
>> patch, but he didn't do that yet. Maybe you two could join forces,
>> make Peter's patch ready for submission (bring up-to-date with trunk,
>> double check and test, and write a log message -- which is missing
>> from your current submission by the way) and submit it to this list?
>> (See also http://subversion.tigris.org/hacking.html#patches)
>>
>> I realise that what I'm asking for is potentially a lot of work,
>> but it would be nice if we had proper custom keywords with support
>> for format strings, rather than just an alias for $Id$.
>>
>> Thanks,
>> Stefan
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] issue #890: Implementation of Custom keywords

Posted by Erik Huelsmann <eh...@gmail.com>.
On Tue, Oct 21, 2008 at 9:44 AM, Kimitake <ki...@gmail.com> wrote:
> Hi Stefan,
>
> Thanks for the comment.
>
> I just tried to apply Peter's patch and quick tested it.
> I used %I for replacing Id keyword, and it seems that it works,
> but when I set $Id$ also after %I keyword, $Id$ is not expanded.
>
> e.g. In "NetBSD=%I Id" case, $Id$ is not expanded.
> e.g. In "Id NetBSD=%I" case, $Id$ and $NetBSD$ are expanded properly.
>
> e.g. In NetBSD=%I Rev Date Author Id case, $NetBSD$ only works,
> others are not expanded.
>
> I will look into it and then send a patch later.

Maybe the patch requires the other keywords to be on separate lines?

Thanks for looking into this!

Bye,

Erik.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] issue #890: Implementation of Custom keywords

Posted by Kimitake <ki...@gmail.com>.
Hi Stefan,

Thanks for the comment.

I just tried to apply Peter's patch and quick tested it.
I used %I for replacing Id keyword, and it seems that it works,
but when I set $Id$ also after %I keyword, $Id$ is not expanded.

e.g. In "NetBSD=%I Id" case, $Id$ is not expanded.
e.g. In "Id NetBSD=%I" case, $Id$ and $NetBSD$ are expanded properly.

e.g. In NetBSD=%I Rev Date Author Id case, $NetBSD$ only works,
others are not expanded.

I will look into it and then send a patch later.

Regards,
Kimitake

On Mon, Oct 20, 2008 at 7:08 AM, Stefan Sperling <st...@elego.de> wrote:
> On Mon, Oct 20, 2008 at 06:25:48AM -0700, Kimitake wrote:
>> Hi subversion developers,
>>
>> I just modified subst.c to support redefine keyword feature like GNU CVS.
>> To use this, add the following to property.
>>
>> NetBSD=Id
>>
>> This example is for NetBSD project, so $NetBSD$ keyword is replaced like
>> $Id$ one.
>>
>> I have submitted this before, but recreated it with trunk.
>
> Issue link for those unaware of what's going on:
> http://subversion.tigris.org/issues/show_bug.cgi?id=890
>
> Kimitake, the patch is neat, but it only solves the case where you
> want to expand $Id$ under a different name.
>
> It would be nice to have a more configurable mechanism.
> Have you seen Peter Wemm's patch at
> http://people.freebsd.org/~peter/svn_keyword.diff ?
>
> Quoting the top of that patch:
>
>  # This patch is an extension of patch in issue #860.
>  # Instead of aliasing one keyword to another, and a big bug (only
>  # supports aliasing to $Id$ anyway), this version allows
>  # keyword_printf() format strings.
>  # svn propset svn:keywords 'Foo=%b Bar=%r' file  (expands $Foo: filename $, etc)
>  # %I is an alias for $id$-like expansion.  I've added %_ to insert a space.
>  # eg: 'CustomId=%b%_Some%_Random%_String'.  The svn:keywords parser doesn't
>  # allow plain spaces.
>  #
>  # it adds to keyword_printf():
>  # %P - $CVSHeader$ like repository-relative paths.
>  # %_ - a space
>  # %R - root of repository
>  # and as aliases in the keyword builder:
>  # %H - alias for $CVSHeader$ expansion. (%P %r %d %a)
>  # %I - alias for $Id$ expansion. (%b %r %d %a)
>  # the keyword builder aliases are because the svn:keyword splitter
>  # uses spaces.
>
> I've asked Peter before whether he could formally submit the
> patch, but he didn't do that yet. Maybe you two could join forces,
> make Peter's patch ready for submission (bring up-to-date with trunk,
> double check and test, and write a log message -- which is missing
> from your current submission by the way) and submit it to this list?
> (See also http://subversion.tigris.org/hacking.html#patches)
>
> I realise that what I'm asking for is potentially a lot of work,
> but it would be nice if we had proper custom keywords with support
> for format strings, rather than just an alias for $Id$.
>
> Thanks,
> Stefan
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] issue #890: Implementation of Custom keywords

Posted by Stefan Sperling <st...@elego.de>.
On Mon, Oct 20, 2008 at 06:25:48AM -0700, Kimitake wrote:
> Hi subversion developers,
> 
> I just modified subst.c to support redefine keyword feature like GNU CVS.
> To use this, add the following to property.
> 
> NetBSD=Id
> 
> This example is for NetBSD project, so $NetBSD$ keyword is replaced like
> $Id$ one.
> 
> I have submitted this before, but recreated it with trunk.

Issue link for those unaware of what's going on:
http://subversion.tigris.org/issues/show_bug.cgi?id=890

Kimitake, the patch is neat, but it only solves the case where you
want to expand $Id$ under a different name.

It would be nice to have a more configurable mechanism.
Have you seen Peter Wemm's patch at
http://people.freebsd.org/~peter/svn_keyword.diff ?

Quoting the top of that patch:

  # This patch is an extension of patch in issue #860.
  # Instead of aliasing one keyword to another, and a big bug (only
  # supports aliasing to $Id$ anyway), this version allows
  # keyword_printf() format strings.
  # svn propset svn:keywords 'Foo=%b Bar=%r' file  (expands $Foo: filename $, etc)
  # %I is an alias for $id$-like expansion.  I've added %_ to insert a space.
  # eg: 'CustomId=%b%_Some%_Random%_String'.  The svn:keywords parser doesn't
  # allow plain spaces.
  #
  # it adds to keyword_printf():
  # %P - $CVSHeader$ like repository-relative paths.
  # %_ - a space
  # %R - root of repository
  # and as aliases in the keyword builder:
  # %H - alias for $CVSHeader$ expansion. (%P %r %d %a)
  # %I - alias for $Id$ expansion. (%b %r %d %a)
  # the keyword builder aliases are because the svn:keyword splitter
  # uses spaces.

I've asked Peter before whether he could formally submit the
patch, but he didn't do that yet. Maybe you two could join forces,
make Peter's patch ready for submission (bring up-to-date with trunk,
double check and test, and write a log message -- which is missing
from your current submission by the way) and submit it to this list?
(See also http://subversion.tigris.org/hacking.html#patches)

I realise that what I'm asking for is potentially a lot of work,
but it would be nice if we had proper custom keywords with support
for format strings, rather than just an alias for $Id$.

Thanks,
Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org