This utility gets all the files
committed by a particulare user in CVS after a specified date and
copies these files into a desired location with original data
structure path.
The original data structure path always
starts with c:\work\PW_Portal.
from cvsgui.Macro import *
from cvsgui.CvsEntry import *
from cvsgui.ColorConsole import *
import cvsgui.App
import os.path, os, shutil
import zipfile, string
import re
from cvsgui.Persistent import *
from cvsgui.MenuMgr import *
from cvsgui.SafeTk import *
class MyConfig(Macro):
def __init__(self):
Macro.__init__(self, "My Utility", MACRO_SELECTION,
0, "My Menu")
self.m_path = Persistent("PY_PATH", "select the destination folder", 1)
self.m_date = Persistent("PY_DATE", "dd-mmm-yyyy", 1)
self.m_name = Persistent("PY_NAME","name",1)
def OnCmdUI(self, cmdui):
cmdui.Enable(1)
def Run(self):
msg = "Please enter the path for delivery :"
msg1 = "Please enter the Date from when you want modified files :"
msg2 = "Please enter the user name whose commited files have to be created in directory structure"
title = "Path"
outputpath = str(self.m_path)
datestr = str(self.m_date)
namestr = str(self.m_name)
res, outputpath = cvsgui.App.PromptEditMessage(msg, outputpath, title)
if res and len(outputpath) > 0:
self.m_path << outputpath
res,datestr = cvsgui.App.PromptEditMessage(msg1, datestr, title)
if res and len(datestr) > 0:
self.m_date << datestr
res,namestr = cvsgui.App.PromptEditMessage(msg2, namestr, title)
if res and len(namestr) > 0:
self.m_name << namestr
cvs = Cvs(1)
console = ColorConsole()
console << kMagenta << datestr << "\n" << kNormal
console << kMagenta << "Username:" << namestr << "\n" << kNormal
okCancel = _cvsgui.PromptMessage("Shall I Continue", "Message", "OK", "Cancel")
if okCancel == 0:
return
code, out, err = cvs.Run("history", "-xACM", "-D%s" % datestr, "-u%s" % namestr)
lines= string.split(out, '\n')
console << kMagenta << "Copying files : " <<"\n"
for line in lines:
#console << kMagenta << line << "\n" << kNormal
mobj = re.match( "^[MCA] \d\d\d\d-\d\d-\d\d \d\d:\d\d \+0000 [a-z_]+ +[\d.]+ +(.*) +(PW_Portal.*) +==",
line)
if mobj:
file_name = mobj.group(1).strip()
dir_name = mobj.group(2).strip()
#console << kBlue << dir_name << "/" << file_name << "\n" << kNormal
srcname = os.path.join("c:/work/", dir_name + '/'+ file_name)
targetname = os.path.join(outputpath, "delivery"+ '/'+ dir_name)
if not os.path.exists(targetname):
os.makedirs(targetname)
shutil.copy(srcname, targetname)
console << kGreen << srcname << " to " << targetname <<"\n" << kNormal
MyConfig()


