#!/usr/bin/env python # # Leo Milano, 2002 # # It recursively does: # cvs -n update (to see what needs to be updated) # cvs add # cvs remove # cvs commit # The recursion is needed to add directory hierarchies # The recursion ends when there are no more changes to commit #### imports import os, sys, fileinput #### variables and constants HOME = os.path.abspath(os.environ['HOME'])+'/' TMP_FILE = HOME+'.cvs_update_results.txt' files_to_add = [] files_to_remove = [] files_to_update = [] #### methods def query_cvs(): print '* quering the server ...' os.system('cvs -qn update > ' + TMP_FILE ) def parse_results(): if os.access(TMP_FILE, os.F_OK): for line in fileinput.input(TMP_FILE): if line[0] == '?': files_to_add.append(line[2:len(line)-1]) if line[0] == "U": files_to_remove.append(line[2:len(line)-1]) if line[0] == "M": files_to_update.append(line[2:len(line)-1]) else: print '* ERROR: could not open temporary file',TMP_FILE sys.exit() def commit(): print '* selecting files to add/remove ...' for file in files_to_add: os.system('cvs add '+file) for file in files_to_remove: os.system('cvs remove '+file) print '* commiting changes ...' os.system('cvs -q commit') def quit(): try: os.remove(TMP_FILE) except: show_msg("* Warning: couldn't remove "+TMP_FILE) print "* nothing else to commit, bye ..." sys.exit() #### Execution starts here os.system('./cvs_clean ') # clean os.system('cvs -q remove') # mark removed files os.system('cvs -q commit') # commit removals os.system('./cvs_update') # bring latest stuff for i in range(5): # no more than 5 recursive commits ;-) # reset files_to_add = files_to_add [0:0] files_to_remove = files_to_remove [0:0] # unnecesary now, remove in future files_to_update = files_to_update [0:0] # print '* starting iteration ',i+1,'...' query_cvs() parse_results() if len(files_to_add)+len(files_to_remove)+len(files_to_update) == 0: quit() commit()