让subversion自动添加Id,Revision等keywords

转载时请标明文章原始出处和作者信息, 作者: lostsnow.
http://www.lsproc.com/blog/add_auto_props_in_subversion/

linux下:

vim ~/.subversion/config

windows下

%APPDATA%\Subversion\config

编辑此文件

[auto-props]
*.html = svn:keywords=Id Revision Date Author
*.php = svn:keywords=Id Revision Date Author
*.css = svn:keywords=Id Revision Date Author
*.js = svn:keywords=Id Revision Date Author

并启用auto-props

[miscellany]
enable-auto-props = yes

这样在 svn add 和 svn import 时就会自动添加keywords

现有的源代码还是没有这个属性,我们得批量的设置一下,一行命令就搞定了(比如我们的目标是当前目录下的所有python源代码文件):

find ./ -type f -name "*.py" | xargs svn propset svn:keywords "Id Revision Date Author"

-- EOF --

Related Posts

3 thoughts on “让subversion自动添加Id,Revision等keywords

  1. @江雪 这个解决不了

    From: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html
    Date
    This keyword describes the last time the file was known to have been changed in the repository, and is of the form $Date: 2006-07-22 21:42:37 -0700 (Sat, 22 Jul 2006) $. It may also be specified as LastChangedDate. Unlike the Id keyword, which uses UTC, the Date keyword displays dates using the local time zone.
    Id
    This keyword is a compressed combination of the other keywords. Its substitution looks something like $Id: calc.c 148 2006-07-28 21:30:43Z sally $, and is interpreted to mean that the file calc.c was last changed in revision 148 on the evening of July 28, 2006 by the user sally. The date displayed by this keyword is in UTC, unlike that of the Date keyword (which uses the local time zone).

    From: http://svn.haxx.se/users/archive-2007-09/0314.shtml
    On 9/10/07, Ryan Schmidt wrote:
    >
    >
    > On Sep 10, 2007, at 16:37, Haixiong Wang wrote:
    > > What I'd like to ask is: is there any way to customize the timezone
    > > used for printing out Id? I know that "Z" stands for Zulu/Standard
    > > time, but is it possible to have local time for Id?
    >
    > No, it's not possible.
    >

    Well, I'd actually put that as "it is not possible at this time", since most
    of the pieces are in place for custom keywords, but some niggling design
    details need to be worked out.

    The other thing to point out is that the reason that the time is displayed
    in UTC is because that is how the files are stored in the repository. It
    means that someone in New York and someone in Hong Kong can check out the
    file and have the same timestamp...

  2. Pingback: 让subversion自动添加Id,Revision等keywords « 软件开发者文摘

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>