eazysvn

Subversion branching and merging made a bit easier

About

Eazysvn is a Python script that simplifies some common operations with Subversion branches. It is based on based on Philipp von Weitershausen's ezmerge.py (which you can find at codespeak.net). It is pure syntactic sugar wrapper around the subversion command-line client, and keeps no extra metadata for helping merges.

The script requires Python 2.7.

Installation

If you have pip, you should be able to easy_install eazysvn.

Alternatively, download it from the Python Package Index: eazysvn.

The source code can be found on Github: https://github.com/mgedmin/eazysvn.

Short introduction/demo

ezswitch

Say you're working on project foobar and in the middle of a difficult refactoring suddenly realize you want to work in a new branch.

~/src/foobar$ ezswitch.py --create my-branch
svn cp svn+ssh://servername/svn/repo/foobar/trunk \
       svn+ssh://servername/svn/repo/foobar/branches/my-branch \
       -m 'create branch'
svn switch svn+ssh://servername/svn/repo/foobar/branches/my-branch .

ezswitch.py prints the commands it executes. You can also run ezswitch.py -n to see the commands it would execute, to make sure it does what you want.

After you've finished hacking, you will want to switch back to trunk and start merging.

~/src/foobar$ ezswitch.py trunk
svn switch svn+ssh://servername/svn/repo/foobar/trunk .

Run ezswitch.py --help for more information.

ezmerge

Say you want to merge the changes committed in revision 1234 of branch my-branch into trunk. You would chdir into a checkout of trunk and do

~/src/foobar$ ezmerge.py 1234 my-branch
Merge revision 1234 from my-branch with

  svn merge -r 1233:1234 svn+ssh://server/svn/repo/foobar/branches/my-branch .

------------------------------------------------------------------------
r1234 | mgedmin | 2007-01-12 02:39:20 +0200 (Pn, 12 Sau 2007) | 10 lines

Fix bug #997: in rare circumstances foobar would silently fail to foobar.

------------------------------------------------------------------------
U    src/foobar/foobar.py

~/src/foobar$ svn commit -m "Merge rev 1234 from my-branch"

ezmerge.py prints the svn merge command it executes. It also shows you the log entries for the revisions you're merging. You can also run ezmerge.py -n to see the merge command it would execute, to make sure it does what you want.

You can merge more than one changeset, e.g. ezmerge.py 1210-1220 my-branch (inclusive range) or ezmerge.py 1209:1220 my-branch (svn compatible half-open range).

You can merge all the changes on the branch with ezmerge.py ALL my-branch or just ezmerge.py my-branch.

You can view a cumulative diff of all the changes made on a branch with ezmerge.py --diff.

Run ezmerge.py --help for more information.

Branch names

Eazysvn expects you to use the traditional repository layout, and can find its way from any of these to any other of these URLs if you specify the desired branch name as 'trunk', 'foo', or 'bar'.

  scheme://server/path/to/svn/repo/trunk/subdirs
  scheme://server/path/to/svn/repo/branches/foo/subdirs
  scheme://server/path/to/svn/repo/branches/bar/subdirs

You do not have to be at the top of the project to switch or merge, any subdirectory will work. If you're merging, ezmerge will ignore any changes outside the subdirectory that you're merging.

Revision numbers

A revision to Subversion means the state of the whole project tree at a given instant of time. Sometimes the changeset that converts one revision to another is more interesting. When you specify a single number N to ezmerge.py, it assumes that you want to merge the changeset that changes revision (N-1) to revision N.

If you specify a range N-M, ezmerge.py merges all the changesets that change revision (N-1) to revision M. For compatibility with svn merge you can specify the revision range as N:M, and ezmerge.py will merge all the changesets that convert revision N to revision M. In the last case N can be greater than M, which is useful if you want to revert some changes.

When you specify ranges (N-M or N:M) M can be a special name HEAD. It means the latest revision in the repository.

You can also specify a special range ALL, which means all the changesets made in the branch. ezmerge.py will parse the output of svn log to get the revision numbers for you.

Full documentation

Full, up-to-date docmentation can be found on the Python Package Index: eazysvn.

There you can learn about other useful eazysvn commands such as ezrevert or eazysvn with its multitude of subcommands.