Publish with Mercurial to Public Environments - mercurial

Basically I am new to using mercurial in a small team environment. I am looking for a way (3rd party if necessary to publish my change-sets/revisions to a public staging and public live server(s).
Currently I have set up on our local ubuntu server, using wildcard DNS, a directory with folders, each folder contains a project. Inside of the folder I create another folder called "repo", this stores the local clean version of my website. Then I clone from that local folder into a custom one, do my work, and push it back into the before mentioned "repo" folder.
Next that "repo" folder connects to a 3rd party site bitbucket. That's so I can work off site.
What I want to figure it out is if there are open source or something to allow me in a web interface, see my revision and select to publish it to one of the 2 server locations. I know beanstalk can do it, but I really like bitbucket and it's cost effective. I have about 15-25 different repositories.
Is my process too much? How can I make this process the most efficient as possible.

Are you using hgweb? It's not clear from your description that you are, and you certainly should be.
That aside, cloning from a central-ish repo to a local working clone, modifying, committing, and pushing bash to the central-ish repo sounds pretty normal.
Why use a web interface to push from your central-ish private repo to your public site? Why not just go from your working clone to the public site?
For example on my local machine (not a web server at all) in the repository for my blog I have this in the .hg/hgrc file:
[paths]
default = ssh://ry4an.org/projects/unblog
publish = https://ry4an.org/hg/unblog
If I do hg pull I get changes from the private repo on my ry4an.org server in my home directory. Then I edit, commit, and hg push which again goes to my private repo on my remote server. When I want to actually publish the blog entry I do hg push publish which pushes the changesets from my local working repository to the public one (at http://ry4an.org/hg/unblog which is the live content for http://ry4an.org/unblog)
In theory I could use a web interface of some sort to move changesets from ssh://ry4an.org/projects/unblog to https://ry4an.org/hg/unblog, but sending them from my local working clone gives me better tools (hg incoming, hg outgoing, hg log, etc.)
Am I fundamentally misunderstanding your goals or was that helpful?

Related

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

Mercurial and online sharing - how to proceed

A noob question... i think
I use Mercurial for my project on my laptop. How do i submit the project to an online server like codeplex?
I'm using tortoisehg and i cant find the upload interface for submit the project online...
From the command line, the command is:
hg push <url>
to push changes a remote repository.
In TortoiseHg, this is accessed through the "Synchronize" function, which seems to show up if you right-click in a Windows Explorer window but not on any file. It's also available in the workbench; the icon is 2 arrows pointing in a circle.
For these things, I find the best way to go is to use the command line interface - TortoiseHG is OK if you need to perform some common operations from the file browser, and it's a nice tool to visualize some aspects of your repository, but it doesn't implement all of mercurial's features in full detail, and it renames and bundles some operations for no apparent reason.
I don't know how things work at codeplex, but I assume it is similar to bitbucket or github, in which case here's what you'd do:
Create an empty repository on the remote end (codeplex / bitbucket / ...).
Find the remote repository's URL - for bitbucket, it is https://bitbucket.org/yourname/project, or ssh://hg#bitbucket.org/yourname/project.
From your local repository, commit all pending changes, then issue the command: hg push {remote_url}, where {remote_url} is the URL of the remote repository. This will push all committed changes from your local repository to the remote repository.
Since the remote's head revision (an empty project) is the same as the first revision in your local copy (because all hg repositories start out empty), mercurial should consider the two repositories related and accept the push.
For an introductory guide to command-line mercurial, I recommend http://hginit.com/

Mercurial, Dreamhost, and Bitbucket

I'm using dreamhost to host a django app, and also the static content for the app. I want to have my static content versioned together with my application code.
Because the dreamhost install of hg is version 1.0.1, to use subrepos at all, one must install ones own version of hg. I have done so.
Once that is done, it is sufficient to create a .hgsub file with the location pointing to another repo, then just add the .hgsub file.
Now, the problem I have is that I want to push to my bitbucket repository, but:
(a) I would need to upgrade my python to be able to use https; and
(b) trying ssh I get the following error:
pushing to ssh://hg#bitbucket.org/marcintustin/oneclickcos
pushing subrepo public to ssh://hg#bitbucket.org/marcintustin/public
remote: conq: repository does not exist.
abort: no suitable response from remote hg!
(To confirm, I have registered my ssh key with bitbucket.)
Any suggestions?
You need to make site a Mercurial repository. Then add a .hgsub file with
project = project
public = public
and make a commit in the site repository. You'll see that it creates and tracks a .hgsubstate file with the changeset hashes of project and public. Make a local clone of site and the subrepositories will follow along nicely.
If that is not enough help, then my suggestion is to read the output of hg help subrepos, the Kick Start guide, and the subrepository wiki page again.
If those guides do not help you along, then come talk to us in #mercurial on irc.freenode.net or on the mailing list. Your question is not very specific and I think it is much easier to discuss this on the proper support channels.

How do I push a new project to a shared Mercurial multi-repository?

I have a local machine ("laptop") and a shared Mercurial repository on another machine ("server").
The shared repository is set up as a multi-repository as described in the Mercurial documentation using Apache, the hgwebdir.cgi script and Mercurial 1.4.
The setup works in the sense that I can browse the projects (repositories) in the web browser, I can clone and pull from the server, and I can push from the laptop when the project/repository already exists on the server.
But I cannot create a new project on the laptop (hg init, do stuff, hg commit) and push it to the shared multi-repository (hg push http://server/hg/my-new-project-name) - I get "abort: HTTP Error 404: Not Found", presumably because the directory/project repository does not exist yet.
How can I push a new project/directory structure to a Mercurial running elsewhere? I couldn't find anything in the documentation, how do you guys do it?
You cannot create new remote repositories over http with the built-in functionality. Your options are to either:
create with a ssh clone: `ssh clone local-repo ssh://you#remote//path/to/repo'
log in to the remote repo and do a hg init where you want the repo. After that you can push to the new empty repo
Use a cheesy http-creation CGI like the one I wrote here: http://ry4an.org/unblog/UnBlog/2009-09-17
Update
I tried using Dropbox as described below, but couldn't make it sufficiently reliable, so I'm not recommending that option.
Original answer below, kept for context.
/update
I found one more option: Skipping both http and ssh altogether and using Dropbox for shared repos.
For the one-person-multiple-computers scenario, it looks like the simplest option of the lot, and you get backups as a nice side effect.
Here is a discussion on Hacker News

Issues with using free Mercurial hosting like Bitbucket

I'm using Mercurial as my SCM, mainly because I like the ability to commit changes to a project even while offline. I'm going to be moving PCs soon and so I decided to look into finding some free Mercurial repo hosting so I don't lose my data. I signed up for a Bitbucket account and I noticed that they offer space for only a single private repository with their free accounts. Wouldn't that mean that some of my stuff might end up publicly available? As in, anyone can download and use it in their projects?
Yes, BitBucket only offers one private repository for free.
Edit: See the comments below, BitBucket now offers as many private repos as you want, the restriction on the free plans is a maximum of 5 users accessing these private repos.
However, if you're just worried about transferring the projects to your new machine, I think BitBucket is overkill. Will you be in possession of both machines at once, even for a short period of time?
If so, I would just use hg serve in each project directory (one at a time) of the old machine and hg clone http://ip.of.old.machine:8000/ projectname to clone the changes onto the new machine.
EDIT: If you're looking for a way to back up without sharing the repos publicly you could get a Dropbox account and clone a copy of each repo to the Dropbox folder on your local machine. Whenever you push changes they'll get synced up to Dropbox automatically.
If you computer catches on fire and you replace it you just install Dropbox and then clone from the repos in the Dropbox folder to your preferred location.
I'm not sure how well this would work if you want to use the Dropbox copy of the repo on multiple platforms (from a Windows box and a Linux box, for example).
run hg bundle --all in all your repositories, stuff the bundles somewhere (like a usb stick), hg unbundle them on the new machine.
Yes, unless you put them all under a single repository. Otherwise, you need to pay them for more private repos.
This must have changed since - you can now have unlimited public and private repos :-)
As an alternative, JavaForge allows hosting private projects.