您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
#!/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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。