How to branch the whole repository including ignore files - mercurial

I have a project, which is in the Mercurial repository. In the root folder there is a .hgignore file, which states, that the "Bin" folder should be ignored (and also some other files and folders).
Now I want to clone this repository but in a way, that ALL folders and files should be cloned, also the original ignored ones. If I just clone the repository, than I get only the files, which are included in the repository thus my bin folder is missing.
How can I get cloned repository with all files in it? I want to merge these two repositories together in a while...
PS - I am working on a legacy application which has a lot of external dll-s in the bin folder of the application. I know I should put them to a seperate folder, but that's another story.

Just copy it.
Copy the whole tree from point a to point b, and the new copy will function perfectly as a repository. The only thing that would be different from a clone is the lack of hardlinks and that the default pull/push path will be set-up to be the same as the original, rather than pointing to the original. That's easy to change by editing .hg/hgrc if you want to.

An ignored file is not in your repository, so it will not be cloned. You should copy these files by hand after you have cloned the repository.
When you copy those files, I think it won't be a problem if you overwrite other files that are in your repository (they're essentially the same files after all), so as long as you don't copy the .hg folder in the root of your checkout, you'll probably be fine.

Related

Remove file from Mercurial repository without distribute a deletion

In my repository somebody committed files that should be unknown (or ignored, according the .hgignore file).
How can I tell to Mercurial to no longer track those files but leave the files as unknown (or ignored) on remote working copies? (With remote working copies I mean working copies of the other users of the repository.)
More details: Specifically those files are .classpath and .project generated by Eclipse IDE when the project was imported as Maven/Gradle project. They have been added to the repository and committed. I want to do not track changes of that files but I don't want to ask everybody to re-import the project into Eclipse again. Renaming .classpath and .project to .classpath.template and .project.template does not resolve my issue.
That is tricky, as the file will be stored as deleted in the changelog when you tell hg to forget it - and on update it will be deleted in the working dirs of everyone who pulls and updates to a rev later than the one where those files have been removed from tracking.
If you can get by with everyone using hg revert -rTRACKED FILENAME where TRACKED is the changeset where the files are (still) tracked, it is not really nice but probably the easiest solution.
You might want to add all files you do not want to be ever tracked to add to your .hgignore so that these won't be added by hg addremove accidentially.

Getting .hg not found with Mercurial repo

Just the other day I was having some problems with my XCode project so I deleted all of the files in my project directory, downloaded my latest commit from BitBucket, and copied all the files from that directory into my empty project directory. Yes I know this was pretty dumb, but now when I try to make a new commit I get: .hg not found. Is it possible to fix this or have I permanently screwed over my repo?
The whole mercurial repository usually remains in your working folder, right under the sub-folder .hg. I say usually, because by deleting your working folder, you also deleted your repo, so yes, it cannot be found anymore. Simply downloading your latest state does not bring it back.
Don't worry, since you had the whole repo in Bitbucket, you only need to reclone. Make a manual backup of your current changes before doing so, if you don't want to loose them.

Mercurial commit with subrepositories in subfolders

I have file/directory structure:
main/.hg
main/subrepo/.hg
main/subrepo1/.hg
I have .hgignore file with such content
.hg
Finally, I want to make a commit in 'main' repository that will include all files in it, including all files from main/subrepo and main/subrepo1 and excluding folders main/subrepo/.hg and main/subrepo1/.hg (so all files from main folder, excluding .hg folders in it will be commited). But Mercurial skips main/subrepo/* and main/subrepo1/*. It does not include this subfolders/subrepos to commit fully. How can I fix this?
I'm going to guess that you have simply created some nested repositories, but not properly linked them as subrepositories.
Make sure that the root of the main repository has a file called .hgsub. You create the file, add the following and then add + commit the file to the main repository:
subrepo = https://path-to-subrepo/
subrepo1 = https://path-to-subrepo1
If the subrepos do not point to some remote server, you would use the local path of course.

Remove Mercurial versioning from a folder

I currently have a project versioned using Mercurial. On my computer, there is a .hg folder in the root of my local repository.
I want to change from Mercurial to Git, so I'm wondering if removing the .hg folder is enough to remove Mercurial versioning from this folder?
If not, what can I do? (I don't want to move the existing sources on my computer).
Yes, all the bits that make it a Mercurial repository are in the .hg folder so you can delete that to remove the Mercurial versioning.
Note though that doing this will obviously lose all your source control history as well.
Looks like there are some options to convert the repository if you want to keep that history, first hit on google:
http://arr.gr/blog/2011/10/bitbucket-converting-hg-repositories-to-git/
yes that should work.
mercurial stores chancesets and so on in the .hg folder, but you will lose all your projects history if you just delete the .hg folder and use git instead then.

Clone Mercurial repository into public_html

I want to clone my Mercurial repository into my /public_html folder on my web server. My Mercurial project looks like this...
- /ProjectName
- /public
- /application
- /config
- /library
What I want is to just get the contents of "ProjectName" into my /public_html folder. Unfortunately, cloning the repository includes "ProjectName" and all of the subfolders are in there.
Any idea how to accomplish this without a symbolic link?
Just to put it out there, you probably don't want a full clone in your public_html unless you really want every version that ever was out there on the web. There's nothing inherently wrong with that, but since you'll have a .hg in public_html people will even be able to clone your repository from it.
Instead consider using the hg archive command which exports all the files as they exist at a specific revision and places them wherever you want.
For example:
cd your_clone
hg archive --rev release /public_html
That takes the code pointed to by the release label (which could be a tag, bookmark, or branch head) and puts the files, but not a full-history clone, in /public_html.
I actually found an easy way to do this.
hg clone https://me#bitbucket.org/me/ProjectName "/home/website/public_html"
public_html has to be empty to clone the repository into it, so I moved everything out, cloned the repo, then moved the pre-existing files and folder back.
Here is a simple step that you can follow:
cd /public_html
hg init .
hg pull ../pathto/ProjectName/
This will pull all the files and folders under ProjectName in public_html without creating /public_html/ProjectName.
But it will still copy all the resources that are in the mercurial repository (Files and Folders) into your directory.