日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

pysvn安装及常用方法

發布時間:2024/4/17 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pysvn安装及常用方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

centos 6.5,svn 1.6.11,pysvn 1.7.6,文章內容來自官網文檔:http://pysvn.tigris.org/docs/pysvn_prog_guide.html

直接用yum安裝即可

yum install pysvn -y

創建一個client

import pysvn def get_login(realm, username, may_save):retcode = True #True,如果需要驗證;否則用Falseusername = 'myuser' #用戶名password = 'mypwd' #密碼save = False #True,如果想之后都不用驗證;否則用Falsereturn retcode, username, password, save client = pysvn.Client() client.callback_get_login = get_login

用這個client進行下面的各種操作

svnurl = 'svn://......' #svn的路徑 outpath = './test' #檢出到的目標路徑 client.checkout(svnurl, outpath) #檢出最新版本 rv = pysvn.Revision(pysvn.opt_revision_kind.number, 1111)) client.checkout(svnurl, outpath, revision=rv) #檢出指定版本
#Revision類型可以通過rv.number獲取對應的數字
entry = client.info('./test') print entry.url #拷貝對應的svn url print entry.commit_revision #最新提交的revision print entry.commit_author #最新提交的用戶 import time t = time.localtime(entry.commit_time) #最新提交的時間 print time.strftime('%Y-%m-%d %H:%M:%S', t) entries_list = client.ls('./other') for en in entries_list:print en.name,en.size,en.time,en.last_author #文件屬性print en.created_rev #文件的revisionprint en.kind #文件類型,file,dir,none,unknown 可以通過str(kind)=='file'判斷 client.update('./test') #更新 changes = client.status('./test')  #檢測狀態,獲取各種新增、刪除、修改、沖突、未版本化的狀態 for f in changes:if f.text_status == pysvn.wc_status_kind.added:print f.path,'A'elif f.text_status == pysvn.wc_status_kind.deleted:print f.path,'D'elif f.text_status == pysvn.wc_status_kind.modified:print f.path,'M'elif f.text_status == pysvn.wc_status_kind.conflicted:print f.path,'C'elif f.text_status == pysvn.wc_status_kind.unversioned:print f.path,'U' tmppath = '/tmp' #對比需要使用臨時文件,這個是臨時文件的位置,會自動清除 print client.diff(tmppath, './svntest') #效果與svn diff一致 client.add('./svntest/add.txt') #添加一個文件到版本控制 client.revert('./svntest/modify.txt') #還原文件的修改 client.move('./svntest/move1.txt', './svntest/move2.txt') #重命名或移動 client.remove('./svntest/delete.txt') #刪除文件或目錄 client.mkdir('./svntest/testdir', '提交message') #新建一個文件夾,提交message這里沒用,當第一個參數是svnurl時直接提交才有用 client.checkin(['./svntest/delete.txt'], '提交message') #提交一個或多個修改 entries_list = client.log('./other', discover_changed_paths=True) for en in entries_list:print en.author,en.date,en.message,en.revision #版本信息for e in en.changed_paths:print '\t',e.path,e.action #版本具體修改的信息

over

轉載于:https://www.cnblogs.com/toSeek/p/6187791.html

總結

以上是生活随笔為你收集整理的pysvn安装及常用方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。