Log in

No account? Create an account
Overloading the Machine -- Day [entries|friends|calendar]

[ website | wjsullivan.net ]
[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

cvs-unlock.py [13 Nov 2004|07:36pm]

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]

post comment

[ viewing | November 13th, 2004 ]
[ go | previous day|next day ]