Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
765 views
in Technique[技术] by (71.8m points)

svn - TortoiseSVN, update revision in file after update (or before commit)

I am attempting to get TortoiseSVN to automatically update a single, specific file in a repository so that it always has the correct $Revision$ when building. I don't greatly care if the $Revision$ is set before commit or after update; either will result in built executables having the correct revision number embedded. The $Revision$ is stored in a version file, which has the $Revision$ keyword property set. I haven't found a good method for doing this. What I have tried so far:

  1. Use a pre-commit hook to call subwcrev on the version file (creating it from a template each time). This works (sort of), and is reliable because it happens on our end (rather than relying on the customer setting up hook scripts correctly which they may fail to do), but it assigns the previous revision number to the file (since the next revision number will be assigned as part of the commit). It also requires the version file to already have been selected for commit, otherwise it will be changed but not committed during this round.

  2. Use a post-update hook to modify the version file, again using subwcrev. This also works, but now I'm relying on the customer setting up the hook, meaning I can still only have limited trust in reported revision numbers.

I have also considered server-side hooks, but according to the documentation they shouldn't be used to modify files after commit, making that a non-starter.

Obviously there's always the option of "the developer should just remember to update the version file each and every time he or she commits, and rely on the keyword properties to update automatically", but we find it is easy to forget this, and it is precisely this step I'm trying to automate.

It seems like a rather common thing that we are trying to do. Is there a better solution than the ones listed above?

The solution we are looking for would be:

  1. Automated, not relying on individuals taking manual steps on every SVN operation.
  2. Reliable, in the sense that the correct revision number is always there when a built is triggered (in particular, at the customer site. If it matters, their repository access is read only).

We primarily access SVN using TortoiseSVN, but are willing to consider another SVN client if it has a mechanism for dealing with this.

question from:https://stackoverflow.com/questions/65936133/tortoisesvn-update-revision-in-file-after-update-or-before-commit

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After a bit of thinking I've come up with the following solution: in TortoiseSVN I'm using a post-commit hook to automatically update the version file after every commit. This ensures that it is included and updated in the next commit as well. This meets all my requirements:

  • It happens on my end, not on the customer site.
  • It is an automated process.
  • The revision number is automatically correct.

The downside is of course that the repository is now always marked as "changed", but that seems to be the lesser evil.

I'm still open to better suggestions if anybody has one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...