Subversion

Manuel-E
2012-07-20
2016-09-06
  • Manuel-E - 2012-07-20

    Hi,

    I am looking for an entry point to the script engine to use the subversion functionality.

    The script example 4 only runs the svn.exe but the documentation on the ScriptEngine shows, there are interfaces for all svn functionalities like update, checkout, comit.

    I am quite new to python (and even newer to IronPython) but I would expect something like this to work:

    proj = projects.primary
    print('Versioned:', proj.is_versioned())
    

    I use CoDeSys 3.5 Patch 4 and the the SVN package (3.5.0.40)

    Could you provide an example, please?

    Best regards
    Manuel

     
  • Anonymous - 2012-07-20

    Originally created by: M.Schaber

    Hi, Manuel,

    As we will very likely support other versioning systems in the future, we did encapsulate the svn functions into their own namespace, to avoid collisions.

    The "global" functions are provided by the "svn" object. Here's an example to access the log of an URL:

    from __future__ import print_function
    url = "svn://localhost/testrepo/trunk/";
    log = svn.get_log(url, slice(-1, 100), 32);
    for entry in log:
    Β  Β  print(entry.revision, entry.time, entry.message, entry.author, len(entry.changes))
    print("Head revsion:", svn.get_log(url, -1)[0].revision)
    Β  Β  
    print("... finished ...")
    

    The project and object specific functions are encapsulated in a "svn" member:

    from __future__ import print_function
    proj = projects.primary
    print(proj.svn.is_versioned)
    proj.svn.commit("Testcommit") 
    
     
  • Manuel-E - 2012-08-21

    Hi M. Schaber,

    I didn't have time to test it, up to today.
    But now it works fine (even with a couple of trailing semicolons )

    I only had to change the url (of course) and the revision-slice:

    head = svn.get_log(url, -1)[0].revision
    log = svn.get_log(url, slice(0, head), 0)
    

    My repository starts with revision 38 and I only get the last entry, when I start with -1.
    But that doesn't really bother me.

    Thanks a lot for the quick help.

    Regards
    Manuel

     
  • Anonymous - 2012-08-22

    Originally created by: M.Schaber

    Hi, Manuel,

    Manuel_E hat geschrieben:
    I didn't have time to test it, up to today.
    But now it works fine (even with a couple of trailing semicolons )

    Sorry for them, it seems I'm clearly writing too much C# code nowadays. I'll try to get a doctors certificate for semicolonitis, and then re-negotiate my contract here.

    Manuel_E hat geschrieben:
    I only had to change the url (of course) and the revision-slice:

    head = svn.get_log(url, -1)[0].revision
    log = svn.get_log(url, slice(0, head), 0)
    

    My repository starts with revision 38 and I only get the last entry, when I start with -1.

    In Subversion, -1 is the head revision, 0 is the "empty" non-revision in an empty repository before the first commit, and 1 is the first actually committed revision.

     
  • francois - 2014-07-25

    Hello,

    Is there a way to get the working copy information as stated in SVN_VERSION_INFO?
    This would be useful to get, at least, the repository URL, and if the working copy is clean, etc.

    This object is non exportable in PLCOpenXML, or native format, and I dont see any members in the scriptlib that allow its access.
    the get_log method needs the URL and posts information as seen on the server, regardless of the working copy.

    Thank you!

     
  • Anonymous - 2014-07-28

    Originally created by: M.Schaber

    Hi,

    There are two entries in our issue database to enable this functionality:

    SVN-33: Expose essential information of versioned objects and projects - this aims to expose information like status, working copy info, log etc. via scripting API.

    SVN-185: Allow read-only access to SVN_VERSION_INFO object - this will expose the ST declaration code as read-only text to the script.

    (External web access to the Jira database for the SVN product may not yet work, this problem is currently worked on.)

    As usual, you can use your official support contact to get you listed as an interested customer in those issues.

    PLCOpenXML Export is currently not planned, but if there is explicit demand, we may as well include it. You can file this as a "Requirement" using your support contact.

     
  • Anonymous - 2014-07-28

    Originally created by: M.Schaber

    Hi,

    SVN-187.

    HTH!

     
  • jking22 - 2015-01-19

    Any suggestions that would detail how to SVN update the entire project via Python Script.

    e.g. looking for python equivalent of:
    >>Project>>SVN>>Update Project

    Pointer to proper documentation would be greatly appreciated.

    Regards,

    John.

     
  • mkeller - 2015-01-19

    Hello jking22.

    To update a versioned project you call the method update() on the project object:

    proj = projects.primary
    proj.update()
    

    You find the SVN related documentation in the ScriptEngine documentation (sub-directory OnlineHelp in the CODESYS directory) under _3S.CoDeSys.SubversionIntegration.ScriptDriver.

    BR
    Martin

     
  • jking22 - 2015-01-19

    Thanks Martin,

    This helps.

    A few comments though...
    1. I think/hope you mean "proj.svn.update()" rather than "proj.update()"... I had to change this to get it to work properly.

    1. The help file seems quite confusing. Do you have a list of common objects? e.g.
      proj.svn.
      project.static_Analysis.???
      *Others?
     
  • mkeller - 2015-01-20

    Hello jking22.

    jking22 hat geschrieben:
    1. I think/hope you mean "proj.update()" rather than "proj.update()"... I had to change this to get it to work properly.
    2. The help file seems quite confusing. Do you have a list of common objects? e.g.
    proj.svn.
    project.static_Analysis.???
    *Others?

    1.) You are right. I never used the SVN Integration with Scripting. I looked through the documentation but missed the part about the ".svn".
    2.) Sorry, but that's the only documentation we have right now. You could try the build-in method dir([object]) to find the modules, classes and objects. See the python documentation.

    BR
    Martin

     
  • Anonymous - 2015-01-20

    Originally created by: M.Schaber

    We know that the current presentation of the documentation is suboptimal, at least, and we have plans to improve the documentation by making it more "pythonic" and include it directly in the online help, in a similar process as we currently establish for the IEC libraries.

    However, other task currently have higher priority, so it was never scheduled for a release.

     
  • lauriollila - 2016-08-25

    Any idea why this following snippet throws ArgumentTypeException when trying to update project with revision number (see comments)...seems that wants to work with timestamp and refuses to take revision number as a parameter...which in our case is irrelevant.

    from future import print_function

    from scriptengine import *

    import datetime
    # 30/06/16 18:00
    date = datetime.datetime(2016, 06, 30, 18, 00)

    projectpath = r'c:\work\Pythontrunk\trunkpython.project'

    proj = projects.open(projectpath)

    #proj.svn.update() # updates to head, works well

    """
    void update_to(
    long revision,
    bool recursive = true,
    bool omit_externals = false
    )
    """

    proj.svn.update_to(867, True, False) # doesn't work: "expected DateTime, got int"
    #proj.svn.update_to(long(867), True, False) # doesn't work: "expected DateTime, got long"
    #proj.svn.update_to(date, True, False) # even this doesn't work : "expected DateTime, got datetime"

    projects.primary.save()

     
  • Thomas233 - 2016-08-26

    lauriollila hat geschrieben:
    Any idea why this following snippet throws ArgumentTypeException when trying to update project with revision number (see comments)...seems that wants to work with timestamp and refuses to take revision number as a parameter...which in our case is irrelevant.

    I can reproduce this error. but i found two workarounds. ether you can user something like:
    proj.svn.update_to(867)
    or
    proj.svn.update_to(revision=867,recursive=True,omit_externals=false).

    M.Schaber hat geschrieben:
    SVN-33: Expose essential information of versioned objects and projects - this aims to expose information like status, working copy info, log etc. via scripting API.
    I am curoius about this issue, but i have no access to Jira.
    I need to get the svn-revision number of a manually checked out project.

     
  • Thomas233 - 2016-09-06

    Can please someone look up if "SVN-33" is planned?

     
  • mkeller - 2016-09-06

    Hi Thomas233.

    Thomas233 hat geschrieben:
    Can please someone look up if "SVN-33" is planned?

    It is not planned. There is no plan for the next release of CODESYS SVN at the moment.

    BR
    Martin

     

Log in to post a comment.