Skip to main content

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

Install

Just type easy_install hgsvn. If easy_install is not available on your computer, download and uncompress the source tarball, then type python setup.py install.

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.

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.

Limitations

SVN externals are purposefully ignored and won’t be added to your Mercurial repository.

There is no straightforward way to push back changes to the SVN repository. For now hgsvn is primarily intended at doing local mirrors, private branches, or patch-driven development (by submitting patches to project maintainers, which is necessary if you don’t have SVN commit access anyway). However, an hgpushsvn command is in the plans that will allow one day to push all changes to SVN automatically.

History

hgsvn 0.1.2

Improvements:

  • Automatically generate .hgignore file. Not only does it produce cleaner output for commands like hg status, but it speeds things up as well.

  • hgpullsvn is more robust in the face of errors and user interruptions.

  • Try to be Windows-compatible by not using the commands module.

  • Remove dependency on the pysvn library; we use the XML output option of SVN commands instead.

Bug fixes:

  • Fix a bug in parent repository detection.

  • Detect the wicked case where the SVN branch has been overwritten with contents of another branch (witnessed with Nose trunk and 0.10-dev branch). We can’t properly handle this situation, so fail with an explicit message.

  • svn info on base repository URL does not always succeed, use the specific project URL instead (reported by Larry Hastings).

hgsvn 0.1.1

Bug 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.

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.2.tar.gz (29.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

hgsvn-0.1.2-py2.5.egg (36.2 kB view details)

Uploaded Egg

hgsvn-0.1.2-py2.4.egg (36.7 kB view details)

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for hgsvn-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bd1717d3db0d6d37f8421659da5d3bedfd1e176b185102c28b6c20804f9610ba
MD5 ae55790c483a2186a18eec66e0627d99
BLAKE2b-256 937748636615c8163078b7d2fd4a5b1fbd7dbc0e6433295a80e8cb787c40676b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hgsvn-0.1.2-py2.5.egg
  • Upload date:
  • Size: 36.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hgsvn-0.1.2-py2.5.egg
Algorithm Hash digest
SHA256 3bf61314cc4c554739520f417cf0d1a33a9cab06d8754482095416c304db0cc0
MD5 b4108add33681d4611ceffde6b7ae52b
BLAKE2b-256 22e29fbdec71149bc6f5ec9878b089d983228e37169f726cb5ea98ee6b45e7e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hgsvn-0.1.2-py2.4.egg
  • Upload date:
  • Size: 36.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hgsvn-0.1.2-py2.4.egg
Algorithm Hash digest
SHA256 4405927e1896f4647a7879cdd25c27ade0e2c9915ce69813993806c0bebac69e
MD5 d536449862b00dcdade42fe8d99f9fac
BLAKE2b-256 6b44087e3ef63f932d07e416f7e218498959ecc8a0a93d7ef07e7d10764e07b9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.0

3 files

0.5.2

1 file

0.5.1

2 files

0.5.0

1 file

0.4.1

2 files

0.3.15

1 file

0.3.14

1 file

0.3.13

1 file

0.3.12

1 file

0.3.11

1 file

0.3.10

1 file

0.3.9

1 file

0.3.8

1 file

0.3.7

1 file

0.3.6

1 file

0.3.5

1 file

0.3.4

1 file

0.3.3

1 file

0.3.2

2 files

0.3.1

1 file

0.3.0

2 files

0.2.6

1 file

0.2.5

2 files

0.2.4

1 file

0.2.3

1 file

0.1.9

1 file

0.1.8

4 files

0.1.7

4 files

0.1.6

4 files

0.1.5

3 files

0.1.4

3 files

0.1.3

3 files

This release

0.1.2 This release

3 files

0.1.1

3 files

0.1

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page