相忘于江湖

泉涸,鱼相与处于陆,相呴以湿,相濡以沫,不如相忘于江湖。《庄子.大宗师篇》

svn2svn.py

Thursday Aug 16, 2007

There's not a good tool to replicate Subversion repository yet.

Although it's easy to use 'svnadmin dump' in server side to replicate the Subversion repositories. But most of the case, we don't have the privilege to access to Subversion server.

There's a client side tool svn2svn.rb though, which is written in ruby. But I don't like the way it works: check out each revision separately, commit back the output from cmd 'diff -Naur [rev-1] [rev]'. This would require a huge amount of disk space when there are lots of revisions and each revision is quite large (my case: 3400+ revisions, 2GB each revision from rev 2000 and on).

So I decided to write a new tool myself. After searching on Internet, I found a related tool: hgsvn, which create Mercurial repositories from Subversion repositories. It's written in Python. There are several modules in svnclient.py are re-usable for my svn2svn tool. So I created svn2svn.py based on it.

Hope I'm not reinventing the wheel. More information can be found from project page:
http://code.google.com/p/svn2svn/


[9] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg

Converting from Subversion to Mercurial

Thursday Jun 14, 2007

As Mercurial is more and more in vogue inside Sun, many workspaces need to be converted from other Source Code Management (SCM) into Mercurial. hgsvn is a good tool to convert SVN based workspaces into Mercurial (HG) based.

  1. Download latest version of hgsvn (current version is 0.1.3):
    http://cheeseshop.python.org/pypi/hgsvn

  2. Untar hgsvn, then install (setup.py will download setuptools during installation):
    $ cd hgsvn-0.1.3
    $ su -
    {passwd}
    # export http_proxy="http://webcache.japan.sun.com:8080/"
    # python setup.py install

  3. Create and pull svn workspace:
    $ mkdir g11n-ws
    $ hgimportsvn http://agc163.prc.sun.com/svn/cws/g11n-ws/trunk g11n-ws
    $ cd g11n-ws
    $ hgpullsvn

  4. voila

 

References:


[4] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg

Differences between Subversion and Mercurial

Thursday May 17, 2007

I'm using both Subversion (SVN) and Mercurial (HG) for source codes management (SCM). There are some differences between them for daily using. I document them in this article and update it when I find new differences.

  1. commit : push
    'svn ci' will commit the server directly
    'hg ci' will commit to local history
    'hg push' will push the changes to server

  2.  locally : globally
    all svn cmds will check current and subdirs only, eg commit, status
    but hg cmds will check globally, including the whole workspace
    if you want to check current and subdirs only, append '.' to hg cmds
    eg, hg status .

  3. partially checkout : fully checkout
    svn can checkout a portion of the workspace (a module or subdir)
    hg can't, it will clone the whole workspace

  4. empty dir
    mercurial will ignore empty dirs when invoking 'hg add', more details
    if you want to add those dirs into mercurial, add a hidden file under it
    $ touch subdir/.hidden
    $ hg add subdir

  5. symbolic link
    mercurial 0.9.3 doesn't support symbolic link file type:

    [qd139970@agc141 rtc]$ hg --version
    Mercurial Distributed SCM (version 0.9.3)

    Copyright (C) 2005, 2006 Matt Mackall <mpm@selenic.com>
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    [qd139970@agc141 rtc]$ hg add RTC_Template_O5U1
    RTC_Template_O5U1: unsupported file type (type is symbolic link)
    [qd139970@agc141 rtc]$

    PS: link1 and link2 mentioned that this feature is supported in trunk.
    PS2: Mercurial 0.9.4 supports symbolic links now(Jun 25, 2007).

  6. account name
    Mercurial will look at $HOME/.hgrc to get the account info when 'hg commit',
    if there's not 'username' entry in $HOME/.hgrc, Mercurial will use
    $USER@$HOSTNAME as the username in log message.
    if this is not what you want, please specify your username in $HOME/.hgrc
        [ui]
        username = [your prefer username]
     
  7. multiple heads
    it's quite easy to create multiple heads in Mercurial workspace.
    you commit new changeset locally, and 'hg pull' from parent workspace
    to get new changesets from team members, then two heads created.
    'hg heads' will show the heads information.
    if multiple heads exist, you need to 'hg up && hg merge && hg commit'
    before you can 'hg push' your changeset to parent workspace.

    one possible way to avoid the mess is running 'hg pull && hg up' before
    you commit any modifications.

    if you enable hgext.fetch extension, 'hg fetch' will do this for you:
    'hg pull && hg up && hg merge && hg commit'

    add following two lines in $HOME/.hgrc can enable hgext.fetch extension
        [extensions]
        hgext.fetch =

[1] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg

Steps to setup SVN over http on Nevada build 59

Thursday Apr 05, 2007

Do following in root privilege.

  1. # ## install svn pkg from Solaris build 61
  2. # ## if you're using snv_61 or later, skip this step
  3. # ## svn version 1.4.0 (r21228)
  4. # pkgadd -d . SUNWneon SUNWsvn SUNWsvnS
  5. #
  6. # cd /etc/apache2
  7. # cp httpd.conf-example httpd.conf
  8. # vi httpd.conf
  9. add two lines in LoadModule session
    1. LoadModule dav_svn_module libexec/mod_dav_svn.so
      LoadModule authz_svn_module libexec/mod_authz_svn.so
  10. add follow at the end of httpd.conf
    1. RedirectMatch ^(/svn)$ $1/
      <IfModule dav_svn_module>
          <Location /svn/>
              DAV svn
              SVNParentPath /workspace/scm/svn/svnroot
              SVNListParentPath on
              SVNIndexXSLT "/svnindex.xsl"
              AuthType Basic
              AuthName "Subversion Repository"
              AuthUserFile /workspace/scm/svn/auth/svn_passwd

              <IfModule authz_svn_module>
                  AuthzSVNAccessFile /workspace/scm/svn/auth/svn_access.conf
              </IFModule>

              # For any operations other than these, require an authenticated user.
              <LimitExcept GET PROPFIND OPTIONS REPORT>
                  Require valid-user
              </LimitExcept>
          </Location>
      </IfModule>
  11. #
  12. # cp /usr/share/src/subversion/tools/xslt/svnindex.xsl /var/apache2/htdocs/
  13. # cp /usr/share/src/subversion/tools/xslt/svnindex.css /var/apache2/htdocs/
  14. # cp /usr/share/src/subversion/www/favicon.ico /var/apache2/htdocs/
  15. # /usr/apache2/bin/htpasswd -cm /workspace/scm/svn/auth/svn_passwd [username]
    New password:
    Re-type new password:
    Adding password for user [username]
  16. # cat <<EOF > /workspace/scm/svn/auth/svn_access.conf
    > [groups]
    > g1 = [username]
    >
    > [/]
    > * = r
    >
    > [test:/]
    > @g1 = rw
    >
    > EOF
  17. #
  18. # cd /workspace/scm/svn/svnroot
  19. # svnadmin create test
  20. #
  21. # svcs -a |grep apache2
    disabled       12:36:52 svc:/network/http:apache2
  22. # svcadm enable svc:/network/http:apache2
  23. #

    That's it! You should be able to browse the svn tree from:

    http://www.example.com/svn/

    Or check out source tree by:

    $ svn co http://www.example.com/svn/test

  24. $ ##
  25. $ ## to create notifications for commit
  26. $ ## as normal user privilege
  27. $ ##
  28. $ cd /workspace/scm/svn/svnroot/test/hooks
  29. $ cp /usr/share/src/subversion/tools/hook-scripts/commit-email.pl.in commit-email.pl
  30. $ vi commit-email.pl
    replace "@SVN_BINDIR@/svnlook" with "/usr/bin/svnlook" in line 54
  31. $ cp post-commit.tmpl post-commit
  32. $ vi post-commit
    add full path to commit-email.pl, replace the email address with the real one,
    add '-s "test project"' before email address,
    comment out line 'log-commit.py ...'
  33. $





 

[96] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg