johnsu01 (johnsu01) wrote,

I use CVS to maintain this site. I'm thinking about switching to something else, but in the meantime, I use CVS. I find frequently that my updates and commits are terminated in process for a reason I haven't figured out yet. When that happens, there are "#cvs.lock" directories left all over the place, and I can't proceed with an update or commit until I remove all of them. I did that by hand once, googled for some better answers, found none, and ended up writing this quickie Python script to recursively remove all of those locks (with the current directory being the top).

I'm just learning Python, so please examine this carefully to make sure that it won't do bad stuff before using it yourself.

import os

def cvsRemoveLocks(directory=os.curdir):
    "starting with 'directory' as top, remove all of the #cvs.locks, recursively."
    for root, dirs, files in os.walk(directory):
        [os.rmdir(os.path.join(root,d)) for d in dirs if "cvs.lock" in d]

Tags: cvs, pyblosxom, python, script
  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.