首页 > 代码库 > svn 调用脚本(-)
svn 调用脚本(-)
#!/usr/bin/ptyhon #coding:utf-8 class SvnCmd(object): #初始化属性,svnpath 为svn的全路径。 def __init__(self,svnpath,tagname = ‘default‘): import commands import time self.svnpath = svnpath self.tagname = tagname self.time = str(time.asctime( time.localtime(time.time()))) #svn状态方法 def svnst(self): import os import commands os.chdir(self.svnpath) status,r = commands.getstatusoutput(‘/usr/bin/svn st‘)[0],commands.getstatusoutput(‘/usr/bin/svn st‘)[1] return status,r #svn预提交方法 def svnpreci(self): import os import commands os.chdir(self.svnpath) commands.getoutput(‘‘‘/usr/bin/svn st|grep -e ‘?‘ | awk ‘{print $2}‘|xargs svn add‘‘‘) commands.getoutput(‘‘‘/usr/bin/svn st|grep -e ‘!‘ | awk ‘{print $2}‘|xargs svn delete‘‘‘) status,r = commands.getstatusoutput(‘/usr/bin/svn st‘)[0],commands.getstatusoutput(‘/usr/bin/svn st‘)[1] return status,r #svn提交 def svnci(self): import os import commands s.chdir(self.svnpath) cmd_svnci = ‘‘‘/usr/bin/svn st|grep -e ‘M‘ -e ‘A‘ -e ‘D‘|/bin/awk ‘{print \$2}‘|xargs svn ci -m "svn ‘‘‘ + self.time + ‘_‘ + self.tagname + ‘"‘ print cmd_svnci commands.getoutput(cmd_svnci) #status,r = commands.getstatusoutput(‘/usr/bin/svn st‘)[0],commands.getstatusoutput(‘/usr/bin/svn st‘)[1] result = commands.getstatusoutput(‘/usr/bin/svn st‘) status,r = result[0],result[1] return status,r #svn更新 def svnupdate(self): import os import commands os.chdir(self.svnpath) #status,r = commands.getstatusoutput(‘/usr/bin/svn update‘)[0],commands.getstatusoutput(‘/usr/bin/svn update‘)[1] result = commands.getstatusoutput(‘/usr/bin/svn update‘) status,r = result[0],result[1] return status,r #svn版本号 def svnrevision(self): import os import commands os.chdir(self.svnpath) #status,r = commands.getstatusoutput(‘/usr/bin/svn info‘)[0], commands.getstatusoutput(‘/usr/bin/svn info‘)[1].split(‘\n‘)[6] result = commands.getstatusoutput(‘/usr/bin/svn info‘) status,r = result[0],result[1].split(‘\n‘)[6] return status,r #svn更新时间 def svnupdatetime(self): import os import commands os.chdir(self.svnpath) #status,r = commands.getstatusoutput(‘/usr/bin/svn info‘)[0], commands.getstatusoutput(‘/usr/bin/svn info‘)[1].split(‘\n‘)[-2] result = commands.getstatusoutput(‘/usr/bin/svn info‘) status,r = result[0],result[1].split(‘\n‘)[-2] return status,r #svn快速回退上一个版本,整个版本回顾,不是临时回滚 def svnrollback(self): import os import commands lately_reversion = int(self.svnrevision()[1].split(‘: ‘)[1]) last_reversion = int(lately_reversion) - 1 os.chdir(self.svnpath) rollcmd = ‘/usr/bin/svn merge -r ‘ + str(lately_reversion) + ‘:‘ + str(last_reversion) + ‘ .‘ print rollcmd result = commands.getstatusoutput(rollcmd) status,r = result[0],result[1] return status,r
svn 调用脚本(-)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。