Automatically include the SVN Revision Number

ruff_hi

Live 4ever! Or die trying
Joined
Oct 24, 2005
Messages
9,134
Location
an Aussie in Boston
I've started to notice that other programs have the revision number as their 4th digit. Something like 12.3.0.12545 ... which means that this is version 12.3, revision number 12545. If the very next revision also coincides with release of 13.0, then the number becomes 13.0.0.12546.

Well, we were doing that but it required a manual edit of a certain file every time - boring, and error prone. I searched tortoise's web site and found a page talking about automatically updating the revision number in your project. The little tool is called in the build (which we don't do with python) so we might need a little bat file to get it updated.
 
Yes, this is my plan for when I automate the release process. You can automatically include a file's revision number in the file itself, but that's not what we want.

What I'll likely do is modify the CvModName.py file with the correct number and commit it (in a script), and this link might help to find that number automatically.
 
That would be actually solving a long-time minor annoyance I had with BUG. The only one, I admit... :D
 
Keep in mind that this doesn't offer the ultimate solution for SVN users. You will not be able to launch Civ4 and see which revision you are synced to with SVN.

I can approximate that (and may do so) by putting the revision tag inside each Python and XML file and write some code to scan them all and take the highest number found for display on the BUG Option screen. This would cover 99.9% of the cases. The only case to fall through the cracks is if we alter an image file alone as they would not have a tag that could be inspected from within Python.

Actually, maybe I can write some Python code to inspect the .svn directories directly. Ah, that would solve the problem entirely for all file types. The only requirement is that you either

  • SVN Checkout directly to CustomAssets, or
  • Point BUG to your SVN Checkout location.
To those that use SVN to acquire BUG, do you checkout directly into CustomAssets or to an alternate location and then copy files?
 
To those that use SVN to acquire BUG, do you checkout directly into CustomAssets or to an alternate location and then copy files?
I only kinda half-use the SVN version right now (copied some updated files through the SVN web interface to test the victory mod stuff without doing a full update :p). Once I finally get around to doing it properly, though, I will most likely check out to an alternate location and then copy files because I like to tweak it with my own changes/additions and don't want to inadvertently overwrite anything while doing an update.
 
...
To those that use SVN to acquire BUG, do you checkout directly into CustomAssets or to an alternate location and then copy files?

i use alternate location and then copy files. then change mod version build number in CvModName.py
 
I like to tweak it with my own changes/additions and don't want to inadvertently overwrite anything while doing an update.

You can let SVN do the merge for you, actually.

Say you check out a file and then add a few lines. If I change and commit a new version of the file, when you do SVN Update it will merge in my changes while keeping yours. The only time you have to intervene (tell SVN what to do) is if we have both changed the same file in way that confuses SVN.

For example, if we both change some text on the same line, SVN won't be able to tell how to merge it. It will mark the locations in the file and tell you there was a merge conflict. After you've resolved your first merge conflict, it's pretty easy.

You could use both methods by checking out into a separate directory and making your changes there. Then copy over into CustomAssets once you like the changes. When you update using SVN, it will merge BUG's changes with yours and you can copy again.

In any case, if you copy the .svn directories along with the files (no problem for Civ), the method I am thinking of will pick up the revision tags.
 
Well, let me explain my setup. I use ruff's excellent Modchanger VB script, so I have three Custom Assets folders. One is the folder where BUG is stored in, the other is one for playing MP that holds only BlueMarble, and the third is a completely default one for playing FfH. So obviously I have my SVN checkout in a different directory and use the export mechanism of TortoiseSVN to update the CustomAssets folder. It's not very elegant, but at least it works...
 
·Imhotep·;7130860 said:
One is the folder where BUG is stored in. . . So obviously I have my SVN checkout in a different directory and use the export mechanism of TortoiseSVN to update the CustomAssets folder.

Given that you export from your SVN folder into a BUG-devoted CustomAssets folder, you can skip this step and merely SVN update directly in that CustomAssets folder.

Civ is quite happy to ignore the .svn folders. I am assuming that Ruff's CA switcher merely renames the CA folders; is this correct? If so, it should work fine.

I'm not saying you need to switch. I'm just giving advice based on my belief that computers should support our laziness. :D It seems to me that the SVN export is superfluous when you already have BUG segregated into its own folder.

·Imhotep·;7130860 said:
One [is] for playing MP that holds only BlueMarble.

Out of curiosity, do you feel that BUG would be an unfair advantage, or is there some other reason why you don't use BUG in MP? AFAIK, BUG should be fully MP-compatible now that the scoreboard has been fixed.
 
·Imhotep·;7130860 said:
Well, let me explain my setup. I use ruff's excellent Modchanger VB script, so I have three Custom Assets folders. One is the folder where BUG is stored in, the other is one for playing MP that holds only BlueMarble, and the third is a completely default one for playing FfH. So obviously I have my SVN checkout in a different directory and use the export mechanism of TortoiseSVN to update the CustomAssets folder. It's not very elegant, but at least it works...
This is pretty much my set up too, except that I have about 15 customasset folders (don't ask). I use the SVN directory as my local backup so that I can play with the code knowing that when I screw up (see latest MA icon example), I don't have to go back to the SVN, just my local version of that.
 
@EF:

I just checked it. Yes, you're right. I could update directly from the SVN without exporting. One question though: Right now the directory structure of BUG in the SVN is BUG Mod with the subdirectories BUG Mod, CustomAssets and PublicMaps. That would mean having a folder BUG Mod in MyGames/.../BeyondtheSword, which is different from the CustomAssets. As I do not want to load BUG as a mod but per CustomAssets - how do I solve the different structure and still be able to use ruff's Modchanger ?

The reason I don't use BUG in MP is that you won't play many games with it. If you enter a game with BUG loaded a *MOD* appears in front of your nickname because the gamefile versions differ from vanilla BTS. Everybody expects you're a cheater then and boots you from the game. And in league play it isn't allowed anyway...

Imhotep
 
·Imhotep·;7131332 said:
Right now the directory structure of BUG in the SVN is BUG Mod with the subdirectories BUG Mod, CustomAssets and PublicMaps. That would mean having a folder BUG Mod in MyGames/.../BeyondtheSword, which is different from the CustomAssets.

This is the correct structure, it's just an unfortunate choice of laying out the directories that we made in the beginning. The inner "BUG Mod" directory that is a sibling of CustomAssets is not a mod folder; rather it contains the configuration and help files for BUG. It should live in "My Games\BtS" along with CustomAssets.

If you checkout or move those three directories into "My Games\BtS", you can rename them and still do an update for each one individually. In fact, you may still be able to do a single update by right-clicking on "My Games\BtS" itself as long as it has a .svn folder in it. I'm not positive about this one since that folder may point to "CustomAssets" directly, but I suppose you could do the update while BUG is the current CA folder.

·Imhotep·;7131332 said:
If you enter a game with BUG loaded a *MOD* appears in front of your nickname because the gamefile versions differ from vanilla BTS.

Ah, that makes sense. I take it people don't play MP with BUG loaded as a mod, eh? Wouldn't that be able to verify that each player has the same version loaded by scanning their Python and XML files?

·Imhotep·;7131332 said:
And in league play it isn't allowed anyway...

Well, we'll just have to change that, won't we? ;)
 
This is the correct structure, it's just an unfortunate choice of laying out the directories that we made in the beginning. The inner "BUG Mod" directory that is a sibling of CustomAssets is not a mod folder; rather it contains the configuration and help files for BUG. It should live in "My Games\BtS" along with CustomAssets.

If you checkout or move those three directories into "My Games\BtS", you can rename them and still do an update for each one individually. In fact, you may still be able to do a single update by right-clicking on "My Games\BtS" itself as long as it has a .svn folder in it. I'm not positive about this one since that folder may point to "CustomAssets" directly, but I suppose you could do the update while BUG is the current CA folder.

Are you trying to tell me that if I move the BUG Mod folder (the topmost one) with the three subdirectories and all the .svn folders into MyGames/.../BeyondtheSword and rename it to CustomAssets BUG will still run properly and I'm able to update via TortoiseSVN too ?

Ah, that makes sense. I take it people don't play MP with BUG loaded as a mod, eh? Wouldn't that be able to verify that each player has the same version loaded by scanning their Python and XML files?

I have not tested it, but that how it works. BlueMarble is different here as it changes only graphics and theme files.

Well, we'll just have to change that, won't we? ;)

Well, to be honest, I do boot players with *MOD* in front too :D . And the league isn't too enthusiastic about Mods too - the chance of cheating is just too big. Besides, the only really helpful thing in BUG for MP use is the whip calculator and the Civ4lerts...
 
·Imhotep·;7131606 said:
Well, to be honest, I do boot players with *MOD* in front too :D . And the league isn't too enthusiastic about Mods too - the chance of cheating is just too big. Besides, the only really helpful thing in BUG for MP use is the whip calculator and the Civ4lerts...
... and the Glance screen so that you can see how different players feel about each other :D:lol:
 
·Imhotep·;7131606 said:
Are you trying to tell me that if I move the BUG Mod folder (the topmost one) with the three subdirectories and all the .svn folders into MyGames/.../BeyondtheSword and rename it to CustomAssets BUG will still run properly and I'm able to update via TortoiseSVN too ?

Not quite. Here's where the two folders with the same name cause confusion.

If you create a new folder and checkout "BUG Mod" and then copy/move the three folders plus the main .svn folder to MG\BTS, you should be able to do SVN Update by right-clicking on MG\BTS

Code:
...\My Games\
    Beyond the Sword\
        .svn
        BUG Mod\
            .svn
            help and INI files
        CustomAssets\
            .svn
        PublicMaps\
            .svn

Technically, I believe you should be able to checkout directly into MG\BTS as long as you rename the existing CustomAssets and PublicMaps folders first. Note: I haven't tried this, but it seems logical. If you try it, I'd love to know and we can add it to our not-yet-written FAQ. :mischief:

·Imhotep·;7131606 said:
Well, to be honest, I do boot players with *MOD* in front too :D . And the league isn't too enthusiastic about Mods too - the chance of cheating is just too big.

But since Civ makes sure both players are using the same mod files, either both can cheat or neither can, right? This would require both run BUG as a mod with Lock Modified Assets checked.
 
·Imhotep·;7132183 said:
@EF:

Just one thing:

You are a genius !!!

Shhh, I'm trying to keep this a secret. :rolleyes:

I'm very glad that worked for ya. I'll write it up in the FAQ when I get back from my trip.
 
What happened to the idea of the original topic btw ? :)
 
Stop reading my mind! *searches for hidden cameras* :eek:

I actually wrote a module tonight that pulls the revision number from the SVN server. I have some code that will parse the local "entries" file for the revision of the working copy (what's on your hard drive). Then it's a simple matter of figuring out the best place to put this information.

Part of what I wrote was to test out if Civ can do multi-threading Python code -- it can! This means that I can have BUG check for the latest revision number in the background while it is initializing itself. The user won't have to wait, and it will gracefully handle when the server is down or slow. I'll probably add a popup to alert you that there's a new version (optional of course).
 
It's astonishing to what this little thing called BUG in the beginning has grown now. Simply amazing!
 
Top Bottom