<p>In my web application I have a file which hold the current revision number via $Rev$. This work fine except, if I don't make any changes to that file, it doesn't get committed.</p>

<p><strong>Is there anyway I can force a single file to always get committed to the SVN server?</strong></p>

<p><em>I'm using TortoiseSVN for Windows so any code or step-by-step instructions would be helpful.</em></p>

[{'answer_id': 5970, 'author': 'Tanerax', 'author_id': 567, 'author_profile': 'https://Stackoverflow.com/users/567', 'pm_score': 1, 'selected': False, 'text': '<p>Depending on your client, some of them offer a pre-commit hook that you can implement something that simply "touches" the file and flags it as changed. If your using something like Visual Studio you could create a post build task that would "touch" the file but you would have to make sure that you do a build before committing changes.</p>\n'}, {'answer_id': 5973, 'author': 'dragonmantank', 'author_id': 204, 'author_profile': 'https://Stackoverflow.com/users/204', 'pm_score': 2, 'selected': False, 'text': "<blockquote>\n  <p>This work fine except, if I don't make any changes to that file, it doesn't get committed.</p>\n</blockquote>\n\n<p>If the file never changes, why would you need it to commmit every single time?</p>\n\n<p>[EDIT]\n@Sean = I understand what he's trying to do, but if the file is never getting updated via a hook or some other process and therefore never changing then SVN will never pick it up.</p>\n"}, {'answer_id': 5974, 'author': 'EndangeredMassa', 'author_id': 106, 'author_profile': 'https://Stackoverflow.com/users/106', 'pm_score': 1, 'selected': False, 'text': '<p>@gradonmantank: Because he wants that file to be updated with the latest revision number. Did you read his question completely?</p>\n\n<p>The pre-commit hook might work.</p>\n'}, {'answer_id': 5978, 'author': 'yukondude', 'author_id': 726, 'author_profile': 'https://Stackoverflow.com/users/726', 'pm_score': 1, 'selected': False, 'text': '<p>I used to have a manual way of doing that. I\'d run a script that would use sed to replace a comment with the current timestamp in my $Rev$ file. That way, the file contents would change and Subversion would commit it.</p>\n\n<p>What I didn\'t do was to take that to the next step: using <a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html#svn.reposadmin.create.hooks" rel="nofollow noreferrer">Subversion\'s repository hooks</a> to automate the process. Trouble is, I\'m not sure if you\'re allowed to change file contents in hooks. The documentation seems to suggest that you can\'t.</p>\n\n<p>Instead, I guess you\'d need a little script that you\'d execute in place of the <code>svn commit</code> command that first updates the timestamp and then runs the normal commit.</p>\n'}, {'answer_id': 5992, 'author': 'Tanerax', 'author_id': 567, 'author_profile': 'https://Stackoverflow.com/users/567', 'pm_score': 2, 'selected': False, 'text': '<p>@gatekiller: It seems TortoiseSVN does support <a href="http://tortoisesvn.tigris.org/tsvn_1.5_releasenotes.html#client-side-hooks" rel="nofollow noreferrer">Client Side Hooks</a>.</p>\n'}, {'answer_id': 5993, 'author': 'Lasse V. Karlsen', 'author_id': 267, 'author_profile': 'https://Stackoverflow.com/users/267', 'pm_score': 1, 'selected': False, 'text': '<p>Committing the file wouldn\'t do you any good. The file isn\'t committed with the full version inside, it is replaced with just the keyword. If you look at the file inside the repository you will see this.</p>\n<p>As such, you need to force the file to be updated in some way instead.</p>\n<p>If you\'re on the Windows platform, you can use the SubWCRev tool, distributed with TortoiseSVN. Documentation <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html" rel="nofollow noreferrer">here</a>.</p>\n'}, {'answer_id': 6014, 'author': 'abyx', 'author_id': 573, 'author_profile': 'https://Stackoverflow.com/users/573', 'pm_score': 1, 'selected': False, 'text': '<p>You can use svn pre-commit-hooks to do it.<br>\nThe general idea I have in mind is create one that before the commit will put the new revision number in the file (get it using svnlook) or maybe change a bogus property on the file (it has to change or SVN will ignore it).</p>\n\n<p>For more information about pre-commit-hooks I found <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="nofollow noreferrer">this page</a> useful.</p>\n'}, {'answer_id': 581533, 'author': 'kokeksibir', 'author_id': 65071, 'author_profile': 'https://Stackoverflow.com/users/65071', 'pm_score': 2, 'selected': False, 'text': '<p>I suggest changing the approach, commiting a file every time means implicitly keeping the global revision number in that file. There user may need another keyword, <strong>GlobalKey</strong>, whose inexistance is explained <a href="http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html" rel="nofollow noreferrer">here</a> I actually have not used mentioned <em>svnversion</em> however, it may lead you to a solution.</p>\n'}, {'answer_id': 581625, 'author': 'dbr', 'author_id': 745, 'author_profile': 'https://Stackoverflow.com/users/745', 'pm_score': 2, 'selected': False, 'text': '<p>Could the revision-number file be changed by a script that deploys your website from SVN to the web-server?</p>\n\n<p>Not sure about on Windows, but using a bash-script, I would do something like..</p>\n\n<pre><code>$ version=$(svnversion)\n$ svn export . /tmp/staging/\nExport complete.\n$ echo "Revision: ${version}" &gt; /tmp/staging/version.txt\n</code></pre>\n\n<p>Then <code>/tmp/staging/version.txt</code> would contain "Revision: 1" (or whatever the highest revision number is).</p>\n\n<p>You could of course replace some identifier in a file, like <code>$Rev$</code> (instead of creating <code>version.txt</code> as per the example above)</p>\n'}, {'answer_id': 581739, 'author': 'Can Berk Güder', 'author_id': 2119, 'author_profile': 'https://Stackoverflow.com/users/2119', 'pm_score': 4, 'selected': False, 'text': "<p>Basically, you want the output of the <code>svnversion</code> command in a file.</p>\n\n<p>Such files are usually kept out of the repository, and automatically created by a build script. I suggest you do the same. If you don't build, but just to a <code>svn up</code> on the server side, just call <code>svnversion</code> after <code>svn up</code> or create a shell script to do both actions.</p>\n\n<p>If you <strong>have</strong> to keep it in the repository on the other hand, calling <code>svnversion</code> in a pre-commit hook would be your best bet.</p>\n"}, {'answer_id': 587244, 'author': 'Stefan', 'author_id': 48003, 'author_profile': 'https://Stackoverflow.com/users/48003', 'pm_score': 4, 'selected': True, 'text': '<p>If you have TortoiseSVN installed, you also have the SubWCRev tool available. Use that tool to get the revision instead of misusing the $REV$ keyword.</p>\n\n<ol>\n<li><p>create a template file which contains your defines, maybe something like</p>\n\n<p>const long WC_REV = $WCREV$;</p>\n\n<p>in a file named version.h.tmpl</p></li>\n<li><p>on every build, call SubWCRev to create the \'real\' file you can use in your application:</p>\n\n<p>SubWCRev path\\to\\workingcopy path\\to\\version.h.tmpl path\\to\\version.h</p></li>\n</ol>\n\n<p>This will create the file version.h from version.h.tmpl, with the text $WCREV$ replaced with the revision your working copy is currently at.</p>\n\n<p>The <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html" rel="noreferrer">docs for SubWCRev</a> might help too.</p>\n'}, {'answer_id': 602819, 'author': 'Chris Dail', 'author_id': 5077, 'author_profile': 'https://Stackoverflow.com/users/5077', 'pm_score': 3, 'selected': False, 'text': '<p>I think you may be not understanding how the $Rev$ flag works. The goal of the Rev flag is not to have this revision always committed into the subversion repository. The goal is that on an update, the Rev flag will always be what the revision is. <strong>You should not need to put code into subversion that contains the revision.</strong> Subversion is very good at keeping track of that information for you.</p>\n\n<p>What you probably missed is that, you need to set a property on the file so that the Revision keyword will be properly processed.</p>\n\n<pre><code>svn propset svn:keywords "Revision" file.txt\n</code></pre>\n\n<p>This will ensure that whenever you do an update, the $Rev: xxx$ flag will be updated with the current revision. You don\'t need to worry about how it is committed to the repository.</p>\n'}, {'answer_id': 604212, 'author': 'James Kingsbery', 'author_id': 72908, 'author_profile': 'https://Stackoverflow.com/users/72908', 'pm_score': 1, 'selected': False, 'text': '<p>I think the best approach to ensuring that there is a file in your web application that has the SVN revision number is to not have a file you commit, but rather to extract it as part of your build script.</p>\n\n<p>If you use maven, you can do this with the maven-buildnumber-plugin.</p>\n'}]
['https://Stackoverflow.com/questions/5948', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/383/']