import os, string, shutil cvsroot = os.path.normpath('/cvsroot/cvsrepo/jsmith') config_file = 'config' config_tmplt = os.path.join('bin', config_file + '.template') cnvr_root = 'cnvr_root' chkpt_dir = 'checkpoints' chkpt_file = 'checkpoint' lines_file = 'lines' p4root_live = os.path.normpath('/p4root') depot_live = os.path.join(p4root_live, 'depot') chkpt_live = os.path.join(p4root_live, chkpt_file) mod_name = 'JSMITHCVSCONVERT_MODULE_NAME' mod_p4root = 'JSMITHCVSCONVERT_P4ROOT' mod_src = 'JSMITHCVSCONVERT_MODULE_DIR' mod_out = 'JSMITHCVSCONVERT_IMPORT_DIR' wantlines = 'JSMITHCVSCONVERT_WANTLINES' wantedlines = 'JSMITHCVSCONVERT_WANTEDLINES' conversion_tags = (mod_name, mod_src, mod_p4root, mod_out, wantlines, wantedlines) def main(): if not os.path.exists(cnvr_root): os.mkdir(cnvr_root) os.mkdir(chkpt_dir) os.mkdir(depot_live) cmd_tmplt = string.Template('perl bin\\$CMD "$MODPATH"') conversion_info = dict() for module in os.listdir(cvsroot): ## if module != 'skel': ## continue conversion_info[mod_name] = module mod_root = os.path.join(cnvr_root, module) conversion_info[mod_p4root] = os.path.join(mod_root, 'p4root') conversion_info[mod_src] = os.path.join(cvsroot, module).replace('\\', '/') conversion_info[mod_out] = '%s_CVS_IMPORT' % module conversion_info[wantlines] = '0' conversion_info[wantedlines] = '' line_list = os.path.join(mod_root, lines_file) mod_chkpt_src = os.path.join(conversion_info[mod_p4root], chkpt_file) mod_chkpt_out = ('%s.%s' % (os.path.join(chkpt_dir, chkpt_file), module)).replace(' ', '_') mod_depot_src = os.path.join(conversion_info[mod_p4root], 'depot', conversion_info[mod_out]) mod_depot_out = os.path.join(depot_live, conversion_info[mod_out]) os.mkdir(mod_root) create_config(mod_root, conversion_info) os.system(cmd_tmplt.substitute({'CMD': 'genmetadata', 'MODPATH': mod_root})) lines = list() for line in file(line_list): line = line.strip() if line in ('import', '===== Lines referenced:'): continue lines.append(line) conversion_info[wantlines] = '1' conversion_info[wantedlines] = '\n'.join(lines) create_config(mod_root, conversion_info) for cmd in ('genmetadata', 'genchanges', 'dochanges', 'dolabels'): os.system(cmd_tmplt.substitute({'CMD': cmd, 'MODPATH': mod_root})) shutil.copy(mod_chkpt_src, mod_chkpt_out) shutil.move(mod_depot_src, mod_depot_out) os.chdir(chkpt_dir) os.system('..\\bin\\perfmerge2 --merge --output %s %s' % (chkpt_live, ' '.join(os.listdir(os.path.curdir)))) os.chdir(p4root_live) os.system('p4d -jr ' + chkpt_file) def create_config(modpath, cnvr_info): config = open(os.path.join(modpath, config_file), 'w') for line in file(config_tmplt): for (tag, val) in cnvr_info.iteritems(): line = line.replace(tag, val) config.writelines(line) if __name__ == '__main__': main()
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 5386 | Jeffery G. Smith |
util.pl:rcsfixfile needs to write out the file no matter what to correct line endings remove hidden attribute on Windows replace %USERNAME% with current username rcsfixup close the streams before renaming the files converter comment out debug code add cvs2p4lblfix |
||
#3 | 5385 | Jeffery G. Smith |
Add initialization script. Add debug code to converter. |
||
#2 | 5224 | Jeffery G. Smith | Improve handling of CVSNT file format. | ||
#1 | 5214 | Jeffery G. Smith | Add support files for my CVSNT conversion. |