Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have been tasked by my boss to look at a system where we create Python scripts and upload them to a server and store details in the DB. He also wants me to implement versioning, so that if any changes are made to a script then the updated version has an incremented version number. This is the area where I am not so sure about.

How would you go about implementing a versioning tool? Is it simply a case of incrementing a field in the Database with the new version number? Or is it more complex than what it initially seems?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

My answer is a question: why would you (re-)implement a versioning tool, when you could couple an existing one with your solution?

Revision Control Systems are here for this very purpose, and are very good at it. I doubt you cannot reuse at least one of them in your context (or please, give us more details), with the appropriate set of features and platform support that you require (see a comparison here and here).

And yes, it is more complex than it seems:

  • Can you have concurrent updates?
  • Do you need to track ownership of each update?
  • Can you have branches?
  • Do you need to be able to trim branches?
  • Do you want to be able to revert to previous versions from a current version?
  • Do you want to be able to compare different versions?
  • This list goes on for a while!

And yes, you can write code to interface with many existing systems.

share|improve this answer
    
FWIW I agree. This is something my boss has asked me to look into. In effect, we are creating a very lightweight sandbox for developing IronPython Scripts using certain exposed C# objects. He wants to implement a one step action to upload the script, and version accordingly. This is without having to explicitly interact with StarTeam. I'm currently having a look at the StarTeam SDK for .Net. Hopefully this will be what I need. Thanks for the answer. –  Darren Young Jun 2 '11 at 12:50
    
@Darren: I don't know StarTeam, but if there's a SDK and exposed interfaces (or even a good command-line access tool), then your approach seems correct. Glad you liked the answer. –  haylem Jun 2 '11 at 12:52
    
@Darren: You could just use a shell script to do the versioning as you upload. e.g., in your upload script, run "hg tip" or a similar command, do some bash-fu to get the revision number, and write that out to a version.py or version.txt file, which then gets read/included in the python script. This sort of thing is a common practice. Alternatively, you can get more complicated auto-build systems which do this for you. –  ProdigySim Jun 2 '11 at 15:22
    
@ProdigySim, @Darren: I don't know about StarTeam, but if that's a CVS or SVN system, those can do that directly in any text file as long as you set up properties (for instance, with SVN properties, use SVN keywords) –  haylem Jun 2 '11 at 15:26
add comment

Sounds like he is asking you to re-invent a version control system. It may sound like a "simple keep your history and revision number" system now, but when opportunity arises more features will be added and you will be headed down the "yet another version control system" road. There are plenty of VCS's about and most support "keyword expansion" which allows the inclusion of "$revision$" or similar keywords which will get expanded by the vcs upon retrieval to the actual revision number.

share|improve this answer
    
Could you link to some "keyword expansion" explanations for Git or SVN or something? –  omouse Jun 2 '11 at 17:36
    
Google is your friend: google.nl/… –  Marjan Venema Jun 2 '11 at 17:40
add comment

If its just Python Script, why not use SVN/Git/Mercurial/Whatever-source-code-versioning-system-you-prefer and a web front end for it?

They all provide version numbers, admittedly of different readability. eg

  • svn provides a version number as a integer that goes up by 1 across the whole repository every time you commit a change.
share|improve this answer
    
We use StarTeam here. Is it possible to write code to interface with it? –  Darren Young Jun 2 '11 at 10:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.