简体   繁体   English

在SVN中提交时添加带有修订号的文件

[英]To add a file with a revision number on commit in SVN

I've not sure if this could be implemented with Subversion, but is there a way to add a file with the revision number on commit? 我不确定是否可以使用Subversion来实现,但是有没有一种方法可以在提交时添加带有修订号的文件?

  • File name: revision.txt 文件名:version.txt
  • Would only have one line: revision number 只有一行:修订号
  • If exists, update with new revision number 如果存在,请使用新的修订号进行更新

UPDATE: 更新:

OK, I've added this option to my SVN configuration 好的,我已经将此选项添加到了SVN配置中

[auto-props]
enable-auto-props = yes
*.php = svn:keywords=Id

Here is the file I'm checking in with SVN (command line) 这是我正在用SVN(命令行)签入的文件

<?php
/**
 * $Id$
 */
?>
$Id$

Looking in the repository I only see the code above and not the revision number. 在存储库中,我只会看到上面的代码,而看不到修订号。

Preface 前言

If you want to have global revision number for repository, you get wrong solution and implement even this bad solution in not optimal way 如果您想要存储库的全局修订版号,则会得到错误的解决方案 ,甚至会以非最佳方式实施此不良解决方案

Face 面对

  • Max revision ID for repository is always accessible inside Working Copy without additional tricks. 始终可以在工作副本中访问存储库的最大修订ID,而无需其他技巧。
 $svn info . ... Revision: 9012 Node Kind: directory ... Last Changed Rev: 5381 ... 

or 要么

$svnversion $ svnversion,如果

9012 9012

  • Revision of file (which differ from repo-revision) can be obtained with pure $Revision$ keyword 可以使用纯$ Revision $关键字获得文件修订(与repo-revision不同)
  • Revision of file is local property, unrelated to repository revisions, show only when this file was changes last time , you have to change file revisions.txt on every commit in your workflow 文件修订是本地属性,与存储库修订无关,仅在上次更改此文件时显示,您必须在工作流程中的每次提交时都更改文件versions.txt
  • I see no reasons for using 1. auto-props 2. for all php-files. 我认为没有理由使用1. auto-props 2.用于所有php文件。 If you want tohave svn:keyword in one file, you can add keyword to this file (revisions.txt) and svn propset for this and only this file 如果要在一个文件中包含svn:keyword,可以将关键字添加到此文件(revisions.txt),并为此文件(仅此文件)添加svn propset
  • svn:keyword will be expanded to it's value inside working copy , all repo-browsers will show source-text without expansion (you can checkout shown file and see all used keywords nicely expanded) svn:keyword将在工作副本中扩展为它的值,所有回购浏览器将显示源文本而不进行扩展 (您可以签出显示的文件,并查看所有使用过的关键字扩展良好)
  • After all, if you want to provide 1. revision number 2. of repository 3. for unversioned copy of your sources (because for versioned WC we already have it), you can think about some type of building system, which, except 'svn export', build needed file with requested data inside exported source tree . 毕竟,如果您想提供1.修订版2.储存库3.的版本号以用于源的未版本化(因为有了版本化的WC,我们已经拥有它),您可以考虑某种类型的建筑系统,除了'svn导出”, 在导出的源树中使用请求的数据构建所需的文件。 Which tools (and technique) to use is OS-dependent (and a question of available tools): SubWCRev on Windows (part of TSVN) works nice, port and equivalent in Tux-world also exist. 使用哪种工具(和技术)取决于操作系统(和可用工具的问题):Windows(TSVN的一部分)上的SubWCRev可以很好地工作,在Tux-world中也存在端口和等效项。 In common - you have versioned template-file, which (as part of build-process) is converted to file with actual fresh data, when you prepare unversioned bundle. 共同点-您具有版本化的模板文件,当您准备未版本化的包时,它会(作为构建过程的一部分)转换为带有实际新数据的文件。 Such way I get from svn.exe export ... z:\\trunk$WCDATE=%Y%m%d$-r$WCREV$ pattern command to export into unique dir-name and the same WCDATE template in text-file replaced with human-readable and informative data, $WCDATE=%Y%m%d$-r$WCREV$ was 20120122-r1143 at latest commit 通过这种方式,我从svn.exe export ... z:\\trunk$WCDATE=%Y%m%d$-r$WCREV$获取svn.exe export ... z:\\trunk$WCDATE=%Y%m%d$-r$WCREV$ pattern命令导出到唯一的目录名,并且替换了文本文件中的相同WCDATE模板使用人类可读且信息丰富的数据, $WCDATE=%Y%m%d$-r$WCREV$在最近一次提交时为20120122-r1143

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM