SVN call Script (-)

Source: Internet
Author: User

#!/usr/bin/ptyhon#coding:utf-8class svncmd (object):         #初始化属性 ,svnpath  is the full path of 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 ]      &nbsP; 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快速回退上一个版本, full version review, not temporary rollback     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 call script (-)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.