Strony

czwartek, 28 stycznia 2010

hacking cvs2svn ;)

Several months ago my BOSS asked me to transfer our ancient CVS repository to the brand new Subversion system. Not a big deal -I thought - there is lovely tool which does it for me: cvs2svn converter made by Tigris. But just after that I realized it wouldn't be such easy task, as our current repository is rather huge and holds several years of our projects history. Some fraction of packages was obsolete and additionally there was a request to split it to three different SVN repos and keep in a newly Subversion repos only recent year of history.

Not a big deal once again - I said after reading of cvs2svn documentation - we've got a database holding all the cvs tags used to built our software, so I'd make a few queries to know what to keep and that's all, except... OMG! There is no "include" pattern for tags!!!

You could in a easy way exclude symbols from cvs, which shouldn't be converted, but I've got completely opposite situation. Now, smart guys, please try to write me a reqexp which is nagative to a pattern... Oups!

What I did it was a little modification of cvs2svn tool in cvs2svn/cvs2svn_lib/symbol_strategy.py:

Then of course I wrote a script which:

  • asked our tag db for packages and their tags/branches that should be migrated
  • generated cvs2svn option file
  • and run cvs2svn tool


Several testing later a big migration day arrived on agenda. I've started to migrate about 9:00 AM and before 6:00 PM ca. 2k packages were moved generating initially about 190k revisions. And one day later we've opened new repos to the whole collaboration.

poniedziałek, 25 stycznia 2010

SVN hooks once again, this time tags, branches, log messages etc.

This one hook I wrote quite long ago is forcing users of Subversion repository to:

  • provide log message on every commit (class logChecker)
  • block removing of "/tags", "/branches" and "/trunk" directories from repo (class pathChecker)
  • forcing branch and tag naming convention
  • making subdirectories under /tags read-only


My company is running Subversion for storing all software packages and our repo hasn't got the default structure (/tags, /trunk and /branches as a top directories) — instead of that every package has got it's own /trunk, /tags and /branches subdirectories. So the repository structure is something like this:

/Path/
PackageA/
trunk/
src/
doc/
tags/
PackageA-00-00-00/
src/
doc/
...
branches/
PackageA-00-00-00-branch/
src/
doc/

PackageB/
...
/OtherPath/
PackageC/
...


Looks rather complicated, but it isn't. ;)

Also we've got tags and branches naming convention. Every tag should be made of package name, then a three (or four for tags made over a branch) groups of digits, e.g.: PackageName-ii-jj-kk or PackageName-ii-jj-kk-ll.
Every branch name is very similar to tag name, except there is additional (-branch) string at the end.

So here is the hook itself:


If you want to use this one, you have to modify it a little:

  • replace 'librarian' or/and 'root' account name with your own repository admin
  • put repository admin mail to block messages - replace this fake 'librarian@mail' address
  • change regexp ffor tags and branches to match your criteria
  • put svn-policy.py script into your repository hook directory ($REPO/hooks)
  • modify "$REPO/hooks/pre-commit" script to switch this one on

    #!/bin/sh
    REPOS="$1"
    TXN="$2"
    SVNPOLICY=/path/to/repo/hooks/svn-policy.py # modify this line
    #SVN policy
    $SVNPOLICY -t "$TXN" "$REPOS" || exit 1
    # All checks passed, so allow the commit.
    exit 0



Maybe the code needs some cleaning and better structure but anyway happy using, comments and questions are welcome!

Cheers,
Krzysztof

piątek, 22 stycznia 2010

rendering graphs in PHP using GraphViz

Well known and very popular graph rendering software Graphviz has got many different language bindings and is widely used in many different areas of maths and computing. I don't have to speak more. It just renders all those graphs in easy way using very simple but powerful language.

Amongst various tools which are using Graphviz there is also a PHP package in PEAR — Image_GraphViz, which has got only one pitfall — it cannot render cluster (a subgraph) inside a cluster (at least not in 1.2.1 version). So, I modified it a bit to make it possible:



Here is the results of running above example on apache (it renders image in svg format, so not all web browsers are able to display it correctly):



Test Graph in SVG

I was very happy when I'd figured out that my changes went into the official Image_GraphViz 1.3.0RC3. Good luck folks!