Design

Design

This is a 20k feet view of the code right now. This may improve with time, or the clarity of the code may improve to a point where such things are less necessary.

This page is out of date; some of the modules mentioned here no longer exist.

Subcommands

Subcommands are created by using the util.register_subcommand decorator to add the function to the lookup table used in svncommand. The docstring is the help text that will be displayed by hg svn help.

demandimport

demandimport is used by Mercurial to reduce startup time. This has the slight problem for hgsubversion that subcommands in files other than svncommand.py won't be found (because the decorator will not execute) until too late. The fix is code like this at the top of svncommand.py:

# dirty trick to force demandimport to run my decorator anyway.
from utility_commands import print_wc_url

What happens here is that demandimport evaluates the utility_commands module during import of svncommand. This causes the decorator to run at the correct time, preventing missing commands.

hg_delta_editor

This is where a special editor subclass lives. This is the editor that is driven by libsvn_ra when replay is used. If the server does not support replay, this code is still used in some places, which is probably a good candidate for a refactor at some point in the future.

svnwrap

A lot of the magic happens here. hgsubversion actually started out as an experiment playing around, and early versions were actually just this wrapper around the lower-level Subversion APIs. The goal is for this package to transparently work on both the ctypes bindings for Subversion (not merged to trunk as of this writing) and the SWIG bindings. This is the package with the best automated test coverage, provided by test_svnwrap.py.

Tests

Lots more could be used. Real automated tests of the actual conversion would be a great way to help the project. At present, the best way to test major changes are to use a local svnsynced mirror of a repository to convert from, and the verify_all_revisions command to double-check the results. Note that you can force hgsubversion to pretend there is no replay support by passing the --stupid flag to svnclone and pull, which allows testing of non-replay changes even locally.

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.