Skip to main content

A set of scripts to work locally on Subversion checkouts using Mercurial

Project description

Summary

This set of scripts allows to work locally on Subversion-managed projects using the Mercurial distributed version control system.

Why use Mercurial ? You can do local (disconnected) work, pull the latest changes from the SVN server, manage private branches, submit patches to project maintainers, etc. And of course you have fast local operations like “hg log”, “hg annotate”…

Currenly two scripts are provided:

  • hgimportsvn initializes an SVN checkout which is also a Mercurial repository.

  • hgpullsvn pulls the latest changes from the SVN repository, and updates the Mercurial repository accordingly. It can be run multiple times.

Example

Making a checkout of the Nose trunk:

$ mkdir nose && cd nose
  # Make SVN checkout, initialize hg repository with first SVN revision
$ hgimportsvn http://python-nose.googlecode.com/svn/trunk
$ cd trunk
  # Pull all history from SVN, creating a new hg changeset for each SVN rev
$ hgpullsvn

Requirements

You first need to install the pysvn library. Unfortunately it is not available as an easy_install package, so it can’t be automated in the setup script. In Debian and Ubuntu this package is named “python-svn” (not “python-subversion” which is a different package). In Mandriva it is named “python-pysvn” (not “python-svn” which is a different package).

Features

Graceful operation

hgpullsvn asks for SVN log entries in chunks, so that pulling history does not put the remote server on its knees.

hgpullsvn can be interrupted at any time, and run again later: you can pull history incrementally.

Metadata

hgsvn reflects commit times (using the local timezone) and commit author names. Commit messages can contain Unicode characters.

File copies and renames as reflected as well, provided they occur inside the branch. SVN externals are purposefully ignored and won’t be added to your Mercurial repository.

Tags

hgpullsvn tags each new Mercurial changeset with a local tag named ‘svn.123’ where 123 is the number of the corresponding SVN revision. Local tags were chosen because they don’t pollute the hg log with superfluous entries, and also because SVN revision numbers are only meaningful for a specific branch: there is no use propagating them (IMHO).

Named branches

These scripts encourage the use of named branches. All updates using hgpullsvn are made in the branch named from the last component of the SVN URL (e.g., if the SVN URL is svn://server/myproj/branches/feature-ZZZ, hgpullsvn will create and use the named branch ‘feature-ZZZ’).

You can thus do local development using your own named branches. When you want to fetch latest history from the SVN repository, simply use hgpullsvn which will update to the original (pristine) branch, leaving your local work intact (you can then merge by yourself if your want).

This also means that hg di -r name-of-pristine-branch will immediately give you a patch against the pristine branch, which you can submit to the project maintainers.

(Note: in a non-trivial setup where you work on several features or bugfixes, you will clone the pristine repository for each separate piece of work, which will still give you the benefit of named branches for quickly generating patches).

Detecting parent repository

If the SVN URL has been created by copying from another SVN URL (this is the standard method for branch creation), hgimportsvn tries to find an hgsvn repository corresponding to the parent SVN URL. It then creates the new repository by cloning this repository at the revision immediately before the creation of the SVN branch.

In other words, let’s say you are operating from myworkdir/. In myworkdir/trunk, you already have an hgsvn repository synced from svn://server/myproj/trunk. You then hgimport svn://server/myproj/branches/new-feature. It will find that the ‘new-feature’ branch has been created by copying from ‘trunk’ at rev. 1138. It will thus create the ‘new-feature’ hg repository by cloning from the ‘trunk’ repository at the revision immediately preceding rev. 1138: for example rev. 1135, identified by the local tag ‘svn.1135’.

This means you will have an hgsvn repository containing two named branches: ‘trunk’ for all the changesets in the trunk before rev. 1138, and ‘new-feature’ for all the changesets in the SVN branch (therefore, after rev. 1138). This way, you can easily track how the branch diverges from the trunk, but also do merges, etc.

History

hgsvn 0.1.1

Fixes:

  • pysvn doesn’t really ignore externals, so use the command line for svn update instead (otherwise we get failures for obsolete URLs)

  • .svn directories were not always ignored.

  • On large repositories, adding more than 32765 files at once failed because of too many arguments on the command line.

  • On slow SVN servers, the chunked log fetching algorithm ended up asking for 0 log entries.

hgsvn 0.1

Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hgsvn-0.1.1.tar.gz (24.9 kB view details)

Uploaded Source

Built Distributions

hgsvn-0.1.1-py2.5.egg (23.8 kB view details)

Uploaded Source

hgsvn-0.1.1-py2.4.egg (24.1 kB view details)

Uploaded Source

File details

Details for the file hgsvn-0.1.1.tar.gz.

File metadata

  • Download URL: hgsvn-0.1.1.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hgsvn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7667cfe35ae84f9eb4036302461334afbdc832e1888b0c3978aa1841cc95f950
MD5 fa32bf3f2f8b6e8cec4f414f348463d3
BLAKE2b-256 d042af76f1f378061f6af19ad89df27e7dd5a369153541a5ec65da267379e928

See more details on using hashes here.

Provenance

File details

Details for the file hgsvn-0.1.1-py2.5.egg.

File metadata

  • Download URL: hgsvn-0.1.1-py2.5.egg
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hgsvn-0.1.1-py2.5.egg
Algorithm Hash digest
SHA256 d064130f3b15cd4bdc1bdb35b2dda76da0a35a65f2688386a1a96ed39d669efc
MD5 7c9ee4e3c8fa42f5f3a07fe1e0c338d5
BLAKE2b-256 b5be8eb69713e56440abd933dd940557764562d5d4e9a26b986f87b84e7e7332

See more details on using hashes here.

Provenance

File details

Details for the file hgsvn-0.1.1-py2.4.egg.

File metadata

  • Download URL: hgsvn-0.1.1-py2.4.egg
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hgsvn-0.1.1-py2.4.egg
Algorithm Hash digest
SHA256 4ae581ecb596daba82d1b0fc417609e0c5a5ed35b3e180c7f3f418c83b9ae3a4
MD5 a6997b9d0f2bf699dcbd29d07e50e74e
BLAKE2b-256 a4f2b3a9a51f7ccd3316155c930ac9b91d7afe9a9333ddc07a15d4e4832b0cfa

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page