Mercurial subrepository different folder - mercurial

I have different repositories on my server, the main repo of the application (MyApplication A, B, C) and the library repo (I'd like to reuse this repo in many applications).
on server side
\\Server\Share\MyApplicationA\
\\Server\Share\MyApplicationB\
\\Server\Share\MyApplicationC\
\\Server\Share\MyLibrary\
When I clone the repo I put the LibraryRepo inside the application in use (A, B or C).
on my computer
C:\MyApplicationA\
C:\MyApplicationA\MyLibrary\
C:\MyApplicationB\
C:\MyApplicationB\MyLibrary\
C:\MyApplicationC\
C:\MyApplicationC\MyLibrary\
This is my .hgsub
MyLibrary = MyLibrary
When I try to push on remote repo (on server) I get this error:
repository Z:/SERVER/Share/MyApplicationA/MyLibrary non trovato
...because the Library Repo on server is on different folder.
I have to create/link the subrepo on server side before?
To manage the repository I use TortoiseHG (Mercurial).
Any suggestion will be appreciated.
Thanks.

I found this solution that work on fake remote repo (fake becasue the remote repo is on my external HD and simulate my SERVER share) but doesn't work on real repo on my server.
Open DOS command line (with Admin rights), write:
mklink /D MyLibrary ".\..\MyLibrary"
How to create symlink on remote path ?
Thanks for any suggestions.

Related

How to automatically keep remote mercurial repository at tip after pushes

I created a mercurial repository on some file servers net share.
Is it possible to automatically get the remote repository updated to tip if somebody pushes its changes?
Because some other people (purely users) may copy the repositories content (rather than cloning, because of lack of .hg) and i want them to get the newest version.
Since it is a share on a simple NAS it would be good if the pushing client could invoke this update.
It seems that a hook on the changegroup event can solve this.
Add the following lines to the repository's configuration file (repo/.hg/hgrc)
[hooks]
changegroup = hg update
This solution was suggested on a slightly different question:
Cloning mercurial repo to the remote host
At least under windows this seems only to work on local repositories. The reason for this is, that hg tries run a cmd on the remote path that fails, since it does not support UNC paths as current direcory.
Adding explicitly the repository url fixes this, but its not client independent anymore.
[hooks]
changegroup = hg update -R %HG_URL%
You could treat the server repository as your "local working directory" and then PULL from your own PC to that location. If you use hg pull --update then it will automatically update the working folder to the latest.
One way to do this is to login to your NAS and physically run the hg command line program there. If not, you could also mount the NAS folder on your local PC and then chdir to its mapped local folder and use your local hg client to do so.
This might seem like an odd thing to do but Mercurial doesn't care which is the "clone" and which is the "server", you can swap them interchangeably in your workflow.

Mercurial connect to webserver

after some research I think I am the only one that is dumb enough to don't understand how to connect to a TortoiseHg on a Webserver with my local Hg.
I can't find any configurations in Hg or am I so stupid and blind?
Can anyone help my helpless brain?
TortoiseHG is simply a GUI for mercurial. It sounds like you are trying to interact with 2 different mercurial repos.
First of all, to connect to the repo on your webserver you have to make sure it is currently serving. You can do this by going onto that box, opening a cmdline with its current directory as your repo, and then typing
hg serve
This will then show a message with a url, like
listening at http://Mywebserver:8000/ (bound to *:8000)
Alternatively, if you have TortoiseHG installed on the webserver, you can rightclick the folder containing the repo, and in the TortoiseHG shell extension click Web Server. In the window that opens, click start to serve the repo.
This repo is now accessible to any machine than can reach that machine and port.
To use TortoiseHG to clone this repo from your local machine ( assuming you have tortoiseHG installed on your machine ):
Open an explorer window, Right click, and in the TortoiseHG shell extension click clone.
In source, enter the url that was displayed when you served on the webserver. For destination, you can enter the name of the folder you would like the repo created in.
A clone of that repo will now be created where you specified.
By default, all its push and pull commands will reference the url of the repo on the webserver. IE, if you do a push or pull cmd on your cloned repo without specify the repo to push or pull to, mercurial will assume it should push or pull to that url.
To interact with the remote repo:
Navigate to the directory containing your repo.
Right click your repo's folder, and in the TortoiseHG shell extension click Synchronize.
You should see that the url field is already filled in with the url you cloned from. You can now click the incoming, pull, outgoing and push buttons to perform those actions.

Tortoisehg on a remote folder (ssh/sftp)

My hg repository is on a server that I can reach with ssh and sftp.
So I can mount the remote dir on my desktop (debian) and can edit the file there.
Now I would like to use Tortoisehg, but I would rather not to clone the repo locally, but just using the remote one that is now mounted locally.
How can I do th?
Now I would like to use Tortoisehg, but I would rather not to clone the repo locally, but just using the remote
It's, in common, The Bad Idea (tm) to use repository from network drive, but:
use this repo the same way, as you edited files in working dir of repository
* Mount to any point of local FS
* Add repository to TortoiseHG Workbench, using "translated" local path to repository
* Use repository as any other really local
But clone|push way is more natural and bullet-proof (no chances to get corrupted repo, real backup of your local repository on remote host)

How to configure mercurial to deploy website folder only

I have a website that I want to deploy to a clients DEV and UAT environments, the site is part of a mercurial repo - it is in the Website folder at the same level as the .hg folder. I know I can push the entire repository but would rather push only the website folder so the client does not have the other files and folders.
The repo looks like this:
Project root
.hg
Database (SQL Source Control uses this)
Documentation (All specs, pdfs, art work etc.)
Lib (pre-Nuget 3rd party dlls)
packages (Nuget stuff)
Website (this is the only area I want to deploy)
.hgignore
Project.sln
Edit:
The clients servers are not connected directly to the internet, my access to them is over a vpn and then RDP. Currently to deploy any changes I need to zip the site up, put it on a shared ftp server then wait up to 3 days for the files to be copied to the servers. Rules have been configured so I can use Mercurial over this connection.
Edit 2
I have managed to create a subrepo from the Website folder by forgetting the Website folder and all it's contents, committing the change then putting the files back, creating a repo then echoing out the .hgsub file. Locally this works for me, I can clone from the Website repo without getting any of the additional folders. However I have not been able to use this version of the repo, even if I repeat the process on our repo server. When I try to clone the hosted version down to my local working copy I get 404 errors, but I can clone the hosted version on the hosting server.
I would appreciate some step-by-step instructions (a guide for dummies if you like) on how to achive my goal; which is to be able to push only the Website folder to the clients servers. The master copy of the repo is on our repo server, I have a local clone and need to be able to push out versions from my copy.
Edit 3
Turns out that the problem I was having converting a folder to a subrepo as described in http://mercurial.aragost.com/kick-start/en/subrepositories/#converting-folder-into-a-subrepository was that the convert command, in versions after 2.1.0, is broken and is still broken in 2.3.1. After I figured that out and rolled back to that version of TortoiseHg I was able to convert the folder to a subrepo, in the root of the repo I have .hgsub which says Website = Website. I was able to work with that locally, commit to the whole repo, the subrepo, clone either the full repo or the subrepo (which is what I want), however I can't get this to work from our master repo server.
I zipped the whole thing up and ftp'd it to our remote master repo server, then set it up so I could clone from it. Directly on the server this works fine (hg clone --verbose -- C:\Repositories\EM .), however when I try to clone from the server to my local development machine with (hg clone --verbose -- https://myserver.com/hg/EM/ .) it fails with "HTTP Error: 404 (Not Found)".
requesting all changes
adding changesets
adding manifests
adding file changes
added 628 changesets with 6002 changes to 4326 files
updating to branch default
resolving manifests
calling hook preupdate.eol: <function preupdate at 0x00000000035204A8>
getting .hgignore
getting .hgsub
getting .hgsubstate
HTTP Error: 404 (Not Found)
[command returned code 255 Fri Apr 20 10:51:23 2012]
I don't know what the problem is, the files are there so why the 404?
In my opinion Mercurial shouldn't be used for this purpose. This is particularly true if that website is a web application because you shouldn't have the DLLs in Mercurial.
You should look at the web deployment tool built into Visual Studio. Have a look at this page to see if it suits your purpose.
If you can't install the required services on the destination server then it can be configured to use FTP instead.
You can not push part of repo tree
If DEV and UAT environments are unversioned targets, you can use any other way for distributing Mercurial content
You can separate Website into subrepo and will be able to push this repo
As others have pointed out you can't use push for this. Just do 'rsync' from your server to theirs. You could even automated that in a hook, where you push to a local repository and it auto-deploys to their site. Something like:
[hooks]
changegroup.deploy = $HG update ; rsync Website account#theirserver:/path/to/docroot
I have a working solution to this. I created a batch file that creates an outgoing repo and starts the built in server so I can pull from it on the client machines. First it clears out the previous folder, then clones from my local working copy (there's a parameter to determine which tag it should clone from). Next it creates a map file and converts the Website folder to a new Website2 folder in order to preserve the history then gets rid of the original folder and renames the new one. Finally it spins up the built in server.
cd c:\inetpub\wwwroot
rd /S /Q _ProjectName
hg clone -- C:\inetpub\wwwroot\ProjectName#%1 C:\inetpub\wwwroot\_ProjectName
cd c:\inetpub\wwwroot\_ProjectName
echo include Website > map.txt
echo rename Website . >> map.txt
hg --config extensions.hgext.convert= convert --filemap map.txt . Website2
cd Website2
hg update
cd ..
hg remove Website/*
hg commit -m "Removed Website"
rename Website2 Website
hg serve
So it isn't pretty, but now I just need to call the batch file and pass the tag I want to build the outgoing website from (uat, dev etc.) and give it a minute to create my Website folder, with history, that I can use to pull from or push from. I don't need to call hg serve because I know the names of the client servers so I can push the changeset out by creating aliased remote repositories. But I included that step so the client machines can pull. I haven't fully explored this option, so I'm not sure whether it's got any particular advantage. It's fine for the case when it's just me working on the project, but if any other developer needs to work on this then the Uri for their local project server will obviously be different (http://SIMON-PC:8000/ won't be the case for everyone), in which case pushing into the client might be best.
But by using this approach my local working repo doesn't need to change and so I don't get any issues communicating with our central repo, the 404 errors mentioned in edit3. I keep the entire history of the repo with the convert process, so the next time I need to send changes I'm not starting at revision 1 - in other words it isn't destructive of the Website and although I am deleting the entire outgoing repo (_ProjectName) each time I am retaining the history and yet in a position to pull / push ONLY the Website directory because it is created each time as a 'standalone' repo

How to move a Mercurial repository created on a local PC to a web server?

I have created and committed to Mercurial repository that was created on my local drive. I now have a remote Windows 2003 web server setup to serve repositories via hgwebdir.cgi.
How do I move the locally created repository to the web server?
It looks like an ftp of the .hg folder on the local drive to the remote web server does the trick. Am I doing it the right way. Is there a more efficient way?
Copying the .hg directory is a completely valid way to do it.
NOTE: You will probably want to exclude, remove or edit the .hg/hgrc file if you have one, as it may contain an absolute path to the original location of the repository.
You could also initialise an empty repository on the remote server, ensure that write permissions are set up correctly, and then run hg push https://wherever. I haven't measured, but I imagine that this method would be slower.