No announcement yet.

SVN Version Control Script

  • Filter
  • Time
  • Show
Clear All
new posts

  • SVN Version Control Script

    Hello all,

    I know the title is a bit generic but I wanted to fully explain with my post. I am part of a team that is using SVN for version control and I am currently trying to create a script (while teaching myself python) that can detect updates being committed by multiple users. The problem we are seeing is if multiple people are working on the same document (.c, .mdl, .csv, etc.) within their own sandboxes (SVN checkouts), then go to commit without first updating their sandboxes to match the trunk, the commit goes into a conflicted state.

    What I would like is for a script to be able to look at the trunk's latest revision number and compare it to a specific user's latest revision number when they try and commit. If that revision number doesn't match, prompt the user to first update their sandbox to the latest revision then commit.

    I remember working for another company where they used GitHub for version control and its logic did this exactly. Can anyone help in how to tackle this issue?

    Thanks in advance

  • #2
    There is always a race condition between 2 people working on the same file. That race can have a wide window (days, weeks, etc.) OR it can have a very short window (sub-seconds). It's all a matter of happenstance and timing.

    Teaching your users to do a checkout before trying to do a checkin is a best practice. But even if you give them a script, the racy-ness of this issue won't be possible to fix all the time.

    Also, note: when working on files that cannot be merged (.jpg) then repository locking should be used to prevent work needing to be thrown away (svn lock).

    As for scripting: you should be able to use "svn info" to get information about the working copy and then use the same URL directly to get information about the repository HEAD. Does that help?


    • #3

      Yes, that is a great start. I appreciate your suggestion on how to possibly proceed.

      It's weird because on the last team I worked on, we would use locking to work on certain docs but this current team, they don't use locking at all. I was hoping a way to automate prompts to teammates that are not readily accessible. The team I work on supports many different programs so a reminder to update sandboxes before commits doesn't seem to be an efficient way to avoid conflicted repositories.