4

i have the following script that i am using to get the log messages from svn

import pysvn
class  svncheck(): 
    def __init__(self, svn_root="http://10.11.25.3/svn/Moodle/modules", svn_user=None, svn_password=None):
        self.user = svn_user
        self.password = svn_password
        self.root = svn_root

    def diffrence(self): 
        client = pysvn.Client()
        client.commit_info_style = 1
        client.callback_notify = self.notify
        client.callback_get_login = self.credentials
        log  = client.log(
        self.root, 
        revision_start=pysvn.Revision( pysvn.opt_revision_kind.number, 0),
        revision_end=pysvn.Revision( pysvn.opt_revision_kind.number, 5829),
        discover_changed_paths=True,
        strict_node_history=True,
        limit=0,
        include_merged_revisions=False,
        )
        print log
    def notify( event_dict ):
        print event_dict
        return   

    def credentials(realm, username, may_save):
           return True, self.user, self.password, True



s = svncheck()
s.diffrence()

when i run this script its returning a empty dictionary object [<PysvnLog ''>, <PysvnLog ''>, <PysvnLog ''>,..

any idea what i am doing wrong here ? i am using pysvn version 1.7.2 built again svn version 1.6.5 cheers Nash

nashr rafeeg
  • 779
  • 3
  • 12
  • 31

2 Answers2

8

pysvn.Client.log method returns a list of log entries; each log entry is a dictionary. (see pysvn Programmer's reference)

you can print log messages in your code like this:

for info in log:
    print info.revision.number,
    print info.author,
    print time.ctime(info.date),
    print info.message
Xie Yanbo
  • 430
  • 6
  • 16
2

finally got this to work, and it seems i did not fully understand how this particular function worked, anyhow... thought i'd share with my mates!

    start_rev = 10
    end_rev = 30
    url = http://dipidi.do.da/svn/foobar
    log_dict = dict((log.revision.number, log["message"]) for log in pysvn.Client().log(url,
                            revision_start=pysvn.Revision( pysvn.opt_revision_kind.number, start_rev ),
                            revision_end=pysvn.Revision( pysvn.opt_revision_kind.number, end_rev ),
                            discover_changed_paths=True,
                            strict_node_history=True,
                            limit=0))
    pprint(log_dict)

if you don't like comprehensions

    for log in pysvn.Client().log(url,
        revision_start=pysvn.Revision( pysvn.opt_revision_kind.number, start_rev ),
        revision_end=pysvn.Revision( pysvn.opt_revision_kind.number, end_rev ),
        discover_changed_paths=True,
        strict_node_history=True,
        limit=0):
    print log.revision.number, log["author"], log["message"]

the comprehension option gives me the following

    {10: 'testing my commits',
     11: 'whohooo this stuff is fun'}
casibbald
  • 2,805
  • 2
  • 16
  • 14