mercurial repository corruption - mercurial

I’m new to mercurial, about 2 months now. We are using it on a new project and tried to create a new repo, a clone of the trunk, to be used as release “branch”.
We use a central repo, everyone is pulling/pushing to/from it over https using hgwebdir.cgi. Using on server hg 1.5.4 and “clients” various versions, 1.5.2 -> 1.6.3
Everything thing was ok. The clone was good (hg verify after clone), the only problem is that very soon this repo got corrupted (empty or missing ; in manifests not found).
The main repo is ok, only this release get broken very soon.
The names of the repos are (folder names and published names, all reside in the same root folder):
A.B – for the trunk
A.B.Release – for the release repo
(read something in the docs, which sounded like this might be a issue – see
One other very strange thing is that checkins made only to trunk (A.B) are seen as available on the release branch, and they are displayed as errors on verify ( in manifests not found). Don’t understand how these got there.
Any clues?

It's not an answer, but I'll state that what you're doing is definitely supposed to work. Making sure the wire-protocol has full backwards compatibility is very important to the Mercurial folks.
The "cross-talk" between your two repos is very concerning and shouldn't happen unless someone erroniously used the share extension.
What if you try creating the A.B.Release clone by using clone --pull rather than clone by itself?

Related

Negative revision when checking HG repository

I'm getting errors when pushing and pulling from a repo on a server. We have a repository (a folder) on a LAN-server which we push our commits to. This worked from the beginning but now it seems to not find the changesets on the server anymore, so tortoisehg ends up by trying to push all the revisions it locally has, to the server.
Also, when I view the repository on the LAN-server in HG workbench, it doesn't show any revision, the only one I can see is a revision -1?
So my question is, what have could gone wrong? And is there a way to fix this? I already replaced the repository on the server with my local one, and that went well for a few days until it happened again.
Revision -1 is what mercurial shows on an empty repository right after a hg init without any commit whatsoever.
If your LAN server exports the repository over a windows network share, indeed it might have been a serious bug fixed in Mercurial 3.3.2 (see https://bz.mercurial-scm.org/show_bug.cgi?id=4546 - maybe you can reproduce that with a new test repo. Upgrade, if that's the case for you)
What Mercurial version are you using?
It's possible that you have been impacted by the bug fixed in Mercurial 3.3.2 (released yesterday).
The solution in that case is to upgrade to Mercurial 3.3.2.

Is it possible to convert a googlecode hg repository to a largefile repository?

I have a remote hg repository hosted on googlecode. Thus I don't have admin access to run e.g. lfconvert on it (as far as I know), and of course lfconvert can only be used on local repositories.
So, is there any way to a convert an googlecode hg repository to a largefile repository?
(one idea is to convert a local clone of the repo to a largefile repo and then push the changes to the "central" googlecode repo, but I fear trying that without knowing if it is a valid approach).
Using your idea to do a local conversion and push, you can take advantage of the 'reset' feature for your repositories:
Do a local clone.
Convert to largefiles: `hg lfconvert normal_repo largefiles_repo``. Do NOT delete the original clone until you are sure everything works.
Reset the hosted repository (See https://code.google.com/p/support/wiki/MercurialFAQ#Mercurial_FAQ).
Push the largefiles repository.
Pushing the largefiles repository without reseting seems problematic because the largefiles repository is essentially a fork of the original one starting at the point the first largefile was committed.
If the push fails*, you can push the original clone and you'll be back where you started without any data loss. (One of the many advantages of DVCS. :-))
The big downside of course is that everybody who has ever cloned your project will now be working from a different fork of the repository. This is always a danger when you do anything involving changing history and is the motivation for Mercurial phases. If you want to be 'kinder', you can start a second project for the largefiles version and place a link at the original project cite describing the move.
[*] I can't figure out from Google Code's documentation whether the largefiles extension is supported. There is a reviewed feature request, but I couldn't find any mention of the request actually being implemented. The push failing would probably be a good indication that largefiles isn't supported though...

Mercurial newbie: Can two pre-existing code bases be synched?

Recently I started working on a "portable" version of a project by copying all the files to a new directory. The portable directory differs from the stable directory only in terms of what has been deleted or commented out; nothing has been added.
I finally decided it's time to learn source control. Everyone says simply starting is more important than anything else, and I ultimately chose Mercurial since it's good for branching and (more importantly) I liked the tutorials I found online (e.g., http://hginit.com and http://hgbook.red-bean.com/).
I made a repository for my stable directory, and a clone in a central repository (Dropbox). I'm committing, pushing, etc. Now, however, I'd like to link my (already existing) portable directory with the central repository. I'd like to be able to, say, fix a bug in my stable code, push it to the central repo, and then pull the bug fix into the portable version--without changing anything else in the portable code.
I'm unsure what to do first with the portable code. If I clone the central repo to the portable directory, won't all my portable code be overwritten the first time I update the portable directory?
You will need to clone the "central" repository to your portable directory before you will be able to do any work like you describe. However, an easy fix is to copy you portable directory somewhere else and create a new, empty folder. Then, clone your repository into that directory. After that, you should be able to just copy and paste your previous portable directory into the cloned version and allow it to overwrite the files there. That will allow you to commit those changes into version control and be in sync with the central repository.
If this method won't work, you will still have to clone the central repository and then make all of your "pending" changes to the existing portable location by hand to your new cloned version.
It sounds like the portable version should be a branch in your stable repo. Since you've already got an existing version that isn't in the repository I think the easiset way to do this is with the addremove command.
What I would do is first make sure any recent changes to your stable branch and make sure you've got a backup copy of your repo somewhere in case anything goes wrong. Then I would delete everything from your stable repository directory except for the .hg directory and any other repository management files such as .hgignore, .hgsub, .hgeol, etc. Then I would copy the portable version into that directory and run hg addremove. The addremove command will automatically add all new files and remove all missing files (which should be just removes in this case). Now I would mark this as a separate branch with hg branch <branch_name> where <branch_name> is whatever you want to name your portable branch. Then just hg commit as usual.
Now you've got your stable branch (called 'default' unless you've renamed it) and your new portable branch. Now when you make changes to the stable branch you can hg update to your portable branch and run hg merge default (or replace default with your stable branch's name) to merge those changes into the portable branch.

How to clone Mercurial to Subversion?

I'm a VERY happy user of bitbucket and mercurial after years of putting up with subversion (and CVS, SourceSafe and others; anybody remember SCCS?). I've considerable project history now in my local hg repo, pushed daily to bitbucket and thence to my home machines.
Problem is, my company wants me to maintain a copy of this history in subversion. And I've hit a stone wall trying to set this up. I've installed hgsubversion, I think correctly. And I've used svnadmin to create an empty svn repository ready to hold the hg history.
But now what? The instructions say to start by pulling a clone (of nose? what's that? I assume this means checkout a copy of the new empty svn directory. OK did that.
But now what? I assume the next step is to push my real local hg clone to the empty svn repo I just checked out. But nothing I've tried will do this. Pull fails as follows, reporting "unrelated repository" (as I recall I gate it the URL of my master local hg repo to get around the "Needs a URL" popup on everything else I've tried.
found new changeset 139d02f4b233
examining 4e97a23b6815:342df9e52cec
abort: repository is unrelated
[command returned code 255 Mon Apr 25 11:29:33 2011]
The result of all this fumbling around is a directory with .hg, .svn and .hgignore entries and nothing else.
So, I feel I'm missing something basic that hundreds of others must have tried by now. Can someone please help me get started? Thanks!
PS: Currently the intent is to maintain SVN permanently as the team repo and push changes there from Hg periodically which would remain the main client for me indefinitely. In case this matters...
You can use the convert extension:
hg convert --dest-type svn mercurialrepo svnrepo
And hgsubversion allows you keep both of them in sync ( bidirectional)
Answered here at SO already:
Converting from Mercurial to Subversion
Migrating from Mercurial to Subversion
Perhaps look at the answers to this question.
Hgsubversion is for working with a repository cloned from SVN using Hg, not the other way around.

Storing separate named branches in mercurial without having to merge them

It's my first time using a DVCS and also as a lone developer, the first time that I've actually used branches, so maybe I'm missing something here.
I have a remote repository from which I pulled the files and started working. Changes were pushed to the remote repository and of course this simple scenario works fine.
Now that my web application has some stable features, I'd like to start deploying it and so I cloned the remote repository to a new branches/stable directory outside of my working directory for the default branch and used:
hg branch stable
to create a new named branch. I created a bunch of deployment scripts that are needed only by the stable branch and I committed them as needed. Again this worked fine.
Now when I went back to my initial working directory to work on some new features, I found out that Mercurial insists on only ONE head being in the remote repository. In other words, I'd have to merge the two branches (default and stable), adding in the unneeded deployment scripts to my default branch in order to push to the main repository. This could get worse, if I had to make a change to a file in my stable branch in order to deploy.
How do I keep my named branches separate in Mercurial? Do I have to create two separate remote repositories to do so? In which case the named branches lose their value. Am I missing something here?
Use hg push -f to force the creation of a new remote head.
The reason push won't do it by default is that it's trying to remind you to pull and merge in case you forgot. What you don't want to happen is:
You and I check out revision 100 of named branch "X".
You commit locally and push.
I commit locally and push.
Now branch X looks like this in the remote repo:
--(100)--(101)
\
\---------(102)
Which head should a new developer grab if they're checking out the branch? Who knows.
After re reading the section on named branchy development in the Mercurial book, I've concluded that for me personally, the best practice is to have separate shared repositories, one for each branch. I was on the free account at bitbucket.org, so I was trying to force myself to use only one shared repository, which created the problem.
I've bit the bullet and got myself a paid account so that I can keep a separate shared repository for my stable releases.
You wrote:
I found out that Mercurial insists on only ONE head being in the remote repository.
Why do you think this is the case?
From the help for hg push:
By default, push will refuse to run if it detects the result would
increase the number of remote heads. This generally indicates the
the client has forgotten to pull and merge before pushing.
If you know that you are intentionally creating a new head in the remote repository, and this is desirable, use the -f flag.
I've come from git expecting the same thing. Just pushing the top looks like it might be one approach.
hg push -r tip