Mercurial commit with subrepositories in subfolders - mercurial

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.

Related

Multiple paths for subrepositories

I have main repository and 12 subrepositories in it. .hgsub contains mappings of local paths and repository hosting URLs. Besides default pull/push URLs for subrepositories, I need to be able to push each subrepository to another server as a standalone repository. So, I add new path alias in .hg/hgrc of each subrepository.
The problem is that aliases are not save anywhere except my local machine, so when I do clean clone of main repository, this aliases are gone and I need to setup them again.
Can I permanently save this path aliases in repository configuration file or maybe there's some workaround for this?
I think the best option available to you is to keep a .hgrc snippet in place in the parent repository filled with [subpaths] entries. For example create subpaths.hgrc as a tracked file in your repository:
[subpaths]
repoa = http://remote/path/to/repo/a
repob = http://remote/path/to/repo/b
Then when you want to initialize those repositories you add this line to your clone's .hg/hgrc:
%include ../subpaths.hgrc
and then comment it out when you want the repoa and repob paths being their usual, local selves.

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.

How to branch the whole repository including ignore files

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.

tortoisehg and subrepos

I can't get Tortoisehg (1.0) to work with subrepos
I have a directory structure like this:
root
.hg
.hgsub
.hgsubstate
Customer1
Project1
.hg
foo.txt
Project2
.hg
Customer2
Project3
.hg
the .hgsub file under root looks like
Customer1\Project1=Customer1\Project1
Customer1\Project2=Customer1\Project2
Customer2\Project3=Customer2\Project3
If modify the file Customer1\Project1\foo.txt and commit from the root it works
>hg ci -m "command line commit"
committing subrepository customer1\project1
in Tortoisehg customer1\project1 is displayed with status S (subrepo)
but when commiting I get a message
abort: customer1/project1: no match under directory!
Is this scenario not supported or am I doing something wrong?
The doc says:
"TortoiseHg 1.0 introduced rudimentary support for subrepositories, and only in the commit / status tool. When Mercurial considers a subrepo as dirty, it will appear in the commit tool as a special entry in the file list with a status of S. If a subrepo is included in the file list of a commit, the subrepo is committed along with the other changes, updating the .hgsubstate file in the main repository root."
I had pretty much the same problem and started trying a whole bunch of variations and I finally got it working for me by using a forward-slash (/) on both sides of the equals sign and not a back-slash (\) anywhere.
So try...
Customer1/Project1=Customer1/Project1
Customer1/Project2=Customer1/Project2
Customer2/Project3=Customer2/Project3
Also, when it was not working, my .hgsubstate file only had a bunch of zeros in it. When it started working, it had a genuine GUID in it.
I was able to get past this problem by committing using the command line for the main repo.
hg commit -m 'Updated subrepo'
I had the same problem:
In one of my repositories committing of one of my changed subrepo modules failed with message
"abort: mysubrepo: no match under directory!"
The reason:
TortoiseHG fails to commit to the subrepository because it handles folder names case-sensitive!
Example:
Your original repository:
C:\Shared\MySubRepo
Cloning this as a subrepo into another repository by command line
hg clone C:\shared\mysubrepo <--- Note the lower cases!
will create a subrepo folder mysubrepo inside your parent repository.
Adding it to the .hgsub file as usual (I always use the platform independent '/' instead of '\', so I don't think that's the reason for the error).
Trying to commit with --subrepos TortoiseHG will end up with the "no match under directory!" error. However, commiting by command line works.
After renaming the subrepo folder mysubrepo to MySubRepo (as the original folder with upper cases) TortoiseHg could commit successfully!
Maybe you have to edit the folder name also in the hgrc file, but I'm not sure if this is really neccessary, because I renamed it in the file before figuring out, that there are canse-sensitive differences in the folder name iteself. Also removing the repository from TortoiseHg Workbench's repository registry and readding it may be needed (and/or restart of the Workbench as well).
I think your problem is with specifying "Customer1\Project1" as a sub repository because Customer1 should be a nested repository as well.
Customer1 and Customer2 should both have '.hgsub' files describing the subrepos inside them (Project1/2)
Remake your Customer1 repository elsewhere and clone Project1 and Project2 into it. Add Project1 and Project2 entries to the '.hgsub' file within Customer1.
Then do the same for a Customer2 repository.
Remember that nested repositories can themselves be nested so create a 'root' repository and then clone Customer1 and Customer2 into it remembering to add entries to the .hgsub file.
Commit 'root' and you should be fine.
The key is to push changes from all instances of a subrepos to its clone master so that other clones that include that subrepos are able to pull that revision if needed.
I have all master repos in the same parent folder on my machine so it makes putting relative paths inside '.hgsub' files such as '../Project1' or '../Customer1' a simple way to push changes to my local clones from our central server.
As far as using TortoiseHG, you will be fine with v1.0 as it will create and manage the '.hgsubstate' file in a nested repository as long as you have already created the '.hgsub' file!
Adding my 2 cents.
I was receiving this error abort: customer1/project1: no match under directory on Windows in the following scenario:
repo was in a folder named MyFolder (note the upper case)
repo had a subrepo
some files (only some!) in the parent repo were commited using myfolder/filename.ext (note the lowercase)
Everything works fine, commandline commits work fine, but Tortoise complains.
Rename the files (find the lowercase ones using hg status --all and you're fine)