I am putting together a build system and wanted to know if there is a reliable way to find out if a checked out SVN folder needs updating (i.e. is it out of sync with the repository). I want to avoid a nightly build unless something has changed. I could write a script that parses the results of the svn update
command I guess, but I wondered if there as a command that would tell me if an update is actually required?
The SVN update Command. The svn update command lets you refresh your locally checked out repository with any changes in the repository HEAD on the server. It also tells you what has been changed, added, deleted. If a change has been made to a file you have also changed locally, svn will try to merge those changes.
When a developer has made changes to the code, those changes are not yet in the repository, but remain on his/her own computer (working copy) until they are 'checked in'. By checking in these changes (or committing them) the developer adds their changes to the repository.
Use the show updates option of the status command:
svn status -u
or
svn status --show-updates
The answer of flolo does not work good for subversion externals (which is also discussed in Don't show svn:externals in svn status). A better solution if you only need the information that the current folder needs a update (not exactly which files itself), this solution is better:
cd somedir;
svn info -r HEAD | grep -i "Last Changed Rev"
Last Changed Rev: 8544
svn info | grep -i "Last Changed Rev"
Last Changed Rev: 8531
If these numbers are not the same, an update is needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With