CentOS 6.5,svn 1.6.11,pysvn 1.7.6, article content from official documents: http://pysvn.tigris.org/docs/pysvn_prog_guide.html
Install directly with Yum
Yum Install Pysvn-y
Create a client
ImportPYSVNdefget_login (realm, username, may_save): Retcode= True#True if validation is required;Username ='MyUser' #User namePassword =' MyPwd' #PasswordSave = False#True, if you do not want to verify after; returnretcode, username, password, saveclient=PYSVN. Client () Client.callback_get_login= Get_login
Use this client to do all of the following
' svn:// ... ' # SVN's Path ' ./test ' # checked out to the target path client.checkout (Svnurl, Outpath) # Check out the latest version of rv = pysvn. Revision (Pysvn.opt_revision_kind.number, 1111)) client.checkout (Svnurl, Outpath, REVISION=RV) # Check out the specified version
#Revision类型可以通过rv. Number to get the corresponding numbers
Entry = Client.info ('./test')PrintEntry.url#copy the corresponding SVN URLPrintEntry.commit_revision#latest submissions from revisionPrintEntry.commit_author#newly submitted usersImportTimet= Time.localtime (Entry.commit_time)#time of latest submissionPrintTime.strftime ('%y-%m-%d%h:%m:%s', T)
entries_list = client.ls ( " ./other Span style= "COLOR: #800000" > " ) for En in entries_list: print en.name,en.size,en.time,en.last_author # file property print en.created_rev # file revision print en.kind # file type, File,dir,none,unknown can be judged by str (kind) = = ' file '
Client.update ('./test') # update
Changes = Client.status ('./test' # detect status, get various new, deleted, modified, conflicting, non-versioned states forFinchChanges:ifF.text_status = =pysvn.wc_status_kind.added:PrintF.path,'A' elifF.text_status = =pysvn.wc_status_kind.deleted:PrintF.path,'D' elifF.text_status = =pysvn.wc_status_kind.modified:PrintF.path,'M' elifF.text_status = =pysvn.wc_status_kind.conflicted:PrintF.path,'C' elifF.text_status = =pysvn.wc_status_kind.unversioned:PrintF.path,'U'
' / tmp ' # The comparison requires the use of temporary files, this is the location of temporary files, will automatically clear Print ' ./svntest ') # the effect is consistent with SVN diff
Client.add ('./svntest/add.txt')#add a file to version controlClient.revert ('./svntest/modify.txt')#to restore a file modificationClient.move ('./svntest/move1.txt','./svntest/move2.txt')#Rename or MoveClient.remove ('./svntest/delete.txt')#Delete a file or directoryClient.mkdir ('./svntest/testdir' ,' submit message' ) #新建a folder, submitting a message here is useless when the first argument is Svnurl.
client.checkin ([ "./ Svntest/delete.txt ", ' Submit Message ") # commit one or more modifications
Entries_list = Client.log ('./other', discover_changed_paths=True) for inch entries_list: print en.author,en.date,en.message,en.revision # version information for inch en.changed_paths: Print ' \ t ', e.path,e.action # version specific changes to the information
Over
PYSVN installation and Common methods