toxicsoftware.com

RANDOMIZE USR 0

toxicsoftware.com header image 2

-tidy

December 18th, 2005 · Comments · Uncategorized

Another quick subversion script. This Python script automatically scans through a ‘ status’ report and automatically removes missing files and adds new files to your subversion repository. Of course you’ll need to commit the changes (or revert back if you made a mistake). This script is a quick and easy way of making a subversion repository match your working directory.

#!/usr/bin/python

import popen2
import re
import os

stdout, stderr = popen2.popen2(' status')

theRegex = re.compile('^(.)[ \t]+(.+)$')

theLines = stdout.readlines()
for theLine in theLines:
    try:
        theLine = theLine[:-1]
        theMatch = theRegex.match(theLine)
        theStatus = theMatch.groups()[0]
        theFile = theMatch.groups()[1]

        theOperation = None
        if theStatus == '!':
            theOperation = 'delete';
        elif theStatus == '?':
            theOperation = 'add';

        if theOperation:
            theCommand = ' %s \'%s\'' % (theOperation, theFile)
            os.system(theCommand)

    except:
        pass

Tags:

Viewing 3 Comments

 
close Reblog this comment
blog comments powered by Disqus