开发者

How can I update SVN keyword substitutions in files other than the modified file?

开发者 https://www.devze.com 2022-12-18 23:22 出处:网络
OK, so I know you can put $Revision$ in a file, and then set the svn:keywords property on that file so that whenever the file is committed, that variable is replaced with the last committed version nu

OK, so I know you can put $Revision$ in a file, and then set the svn:keywords property on that file so that whenever the file is committed, that variable is replaced with the last committed version number.

I'd like to use this concept to implement a smart caching layer for my template files. I plan on using the svn revision number as part of the key to look up from cache.

Here's some psuedo-code:

function get_from_cache(){
   $key = 'TEMPLATE_CACHE_$Revision$';
   $template = a开发者_开发问答pc_fetch($key);
}

The catch is, I want $Revision$ to be replaced with the current revision number every time a file is committed in the templates/ directory, not every time a file containing the get_from_cache() function is committed. How can I do this?


You can't do this with keywords. Instead, you can use some scripting to retrieve the last revision of your working copy or the last revision on the svn server and replace it in your script file containing the get_from_cache() function.

You could also set up a post-commit hook that publishes the latest revision of that folder after each commit and retrieve that in some way.


It's not directly possible. You could script an update to this file whenever a template is updated, but that's ugly (and will mess up your history).

Easier would be to make the script which does the update on your live server also make a modification to a file (or perform another action, like explicitly clearing the cache) to achieve the same effect.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号