How to Fork a Mercurial Project on SourceForge

Forking a Mercurial project on SourceForge isn’t as straight forward as one might think. If you jump straight to fork without first creating a project, you are going to end up with a personal tool.

CSScintilla originally forked as personal tool

A personal tool is fine if you are working on a new feature you hope might one day be included in the project from whence you forked. In my case I was adding CopperSpice support to Scintilla because Qt no longer qualifies as OpenSource with the removal of an OpenSource LTS. The community isn’t allowed to create on on their own. Many projects and some Linux distros are now removing all things Qt. Debian no longer has any Qt maintainers. They are using the KDE project repos but many/most Debian based distros have long since dropped KDE as a supported desktop, instead favoring desktops with less bloat and fewer useless applications.

Scintilla didn’t want to absorb yet another cross platform library which was fine. I need CsScintilla for the next release of RedDiamond because syntax highlighting with QPlaneTextEdit and Regular Expressions just sucked on big files.

So, I went the path most will go with Mercurial.

  • Forked project to personal tool
  • Finished what you were working on and now want to make this available to others
  • You also want to maintain the ability to pull updates into your code from the original project
  • Gee, how do I do that?

The part that isn’t obvious

When you fork a Mercurial based project you have to fork it into something. Let me show you some shots.

Choosing to fork Scintilla
If you take the defaults you get a personal tool

How to go from personal tool to project

First you must create a new project. This is the counterintuitive part, but you cannot create a new project via fork with Mercurial like you can with Git and many other Source Code Management (SCM) tools.

Choose Create
Create Your Project Now

You will note that there is an “import from GitHub” button. SourceForge is where professionals go. GitHub is for hacks and kids still wet behind the ear. Yes, I have GitHub projects. They are things that got forked from other things that were on GitHub. In the case of the CppLinuxSerial I need to kill that unless I do more. The changes were almost instantly rolled into the base project. When I finally complete the others they will move to SourceForge.

Choose a Project Name and accept the URL
Actually create

Yes, you are going to be taken to that annoying “looks like your project is empty” page. Ignore it. You do need to select the project url and paste it into a text editor somewhere.

Now the real fun begins

Zip your entire directory tree up and copy it off some place for safe keeping. If you luggie this up you can at least get back to where you where.

Your personal project had a url underneath your user id because it was personal.

The personal project url
Edit hgrc and change the url

You will notice that I changed

default = ssh://

to be

default = ssh://

because that is the project I created and the all lowercase name was the mountpoint.

I was a good little geek when making my changes. I put them all in my own branch. Mercurial is a bit picky about creating new branches with a push. It wants you to tell them you really mean it.

Now go back and look at the code in your project

You’ve got code!

My branch is there along with its new directories. Life is good . . . almost.

You still need to get updates from the base project

how to get stuff from base
hg pull -u

That pulls all of the stuff from the original scintilla base into my local working directory and project. It is not pulled into your branch! In particular the changes I wanted are in the default branch.

hg merge default
hg stat
hg addremove
hg commit --message "some message"

Let’s make it official

At this stage I have a shiny new SourceForge Mercurial based project called CsScintilla. My project really is just Scintilla at this point because all of my code is in CsScintilla branch. It is time for it to be an official project. Many thanks to Alexandra Zaharia for this nugget of information.

hg up default
hg merge CsScintilla    
hg ci -m "merge CsScintilla branch into default"
hg push
merging my branch into default

Be certain you wait for that repository refresh that got queued to finish. You should get an email notification. Once that happens you can take a look at default.


Life is good! The default branch now has my changes. Mercurial is cumbersome, but you can make it work.

Get rid of those unwanted branches

Last but not least we need to get rid of that development branch.

hg up CsScintilla
hg ci -m "closing CsScintilla development branch" --close-branch
hg addremove
hg stat
hg push

Yes, I did some technically unnecessary steps there, but I like to be thorough.

closing branch

Probably need a bit of explanation here.

Close closes the branch locally

SourceForge appears to have a much longer memory.