Phill Pafford
Phill Pafford

Reputation: 85298

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?

UPDATE:

OK, I've added this option to my SVN configuration

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

Here is the file I'm checking in with SVN (command line)

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

Looking in the repository I only see the code above and not the revision number.

Upvotes: 3

Views: 7863

Answers (2)

Lazy Badger
Lazy Badger

Reputation: 97280

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.
$svn info .

...

Revision: 9012
Node Kind: directory

...

Last Changed Rev: 5381

...

or

$svnversion

9012

  • Revision of file (which differ from repo-revision) can be obtained with pure $Revision$ keyword
  • 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
  • I see no reasons for using 1. auto-props 2. for all php-files. 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 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)
  • 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. 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. 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

Upvotes: 1

BD.
BD.

Reputation: 890

Perhaps this would help:

http://www.startupcto.com/server-tech/subversion/setting-the-id-tag

Upvotes: 2

Related Questions