PYSVN installation and Common methods

Source: Internet
Author: User

CentOS 6.5,svn 1.6.11,pysvn 1.7.6, article content from official documents:

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 = ('./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 = ( " ./other  Span style= "COLOR: #800000" > " )  for  En in   entries_list:  print,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.message,en.revision    # version information     for inch en.changed_paths:         Print ' \ t ', e.path,e.action    # version specific changes to the information


PYSVN installation and Common methods

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: 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.