I am using Mercurial with tortoiseHg, and I have few repositories around my computer (because i work with different languages at the same time).
I would like to have a backup of all my repositories that I would trigger manually (ideally with an icon on my desktop).
I am open to many backup solution, like using dropbox, or using another computer on the same network or both solutions at the same time.
Which is the best solution and how can I implement it?
I am using windows 7
One option is to import your repositories into a Mercurial hosting service like Bitbucket and then use the built-in push feature of Mercurial to periodically copy your local changes to the remote clone. You can find instructions on how to import an existing repository into Bitbucket here.
A repository hosting service like BitBucket will allow you to to not only backup your repositories but also get them off site giving you recovery options in case of a significant catastrophe plus allow you to easily share your work with others if you so desire.
If you just want to backup the repository, you can use any method you want (even just copying files) to grab a copy of the project's .hg directory. At work, we use a central repository on the corporate network that is backed up, fire and access protected.
Related
I don't really know how to search for this question so please direct me if it has already been asked.
I'm new to mercurial and we have a problem with our current repo organization:
Our current repo organization is that we each have our own working repositories (for each project) that we pull and push to a master repo (also for each project).
The problem is that our working repos are located on the company server (along with the master repo) and building from our working repo on the server is causing our build times to be exceedingly high (i.e. 40-50 seconds when building on our local hard drive takes about 1 second).
The obvious solution seems to be to move our working repos to our local hard drive and to push/pull to and from the master repo on the server.
One issue with this is that the working repo is now physically on our local hard disk and won't be backed up on the company server.
Is there a way to create a "shadow" working repo (located on the server side) that will permanently remain synced to each of our individual working repos (located on our local hard disk), and then push/pull from one of these to and from the master repo?
This way we will benefit from the reduced build times in addition to having all data from our working repos backed up on the server.
Thanks for any input/advice,
Shaun
Generally you can only exchange committed changesets among repositories. Additionally they have to be of at least phase draft. There is no way inside mercurial to share the state of the working directory.
You probably want to get used to committing often and atomically. You can make it easily automatic to push every commit you make locally to the central server by means of commit hook.
Additionally you probably should consider to make your central server a non-publishing server. That means that you can push commits in draft phase and they will remain in that phase, thus mutable. That way you can also push draft work there which can later be edited. You'll have to change manually phase to public on those changesets which you consider 'done'. The changeset evolution extension of mercurial might come in handy
You keep a copy of the repository on the company server (so that it will be backed up) and a copy on your local drive (so that you can compile it easily). You keep the copies in sync with push/pull.
Forgive me if this question sounds ridiculously naive, but I don't seem to be able to find a straightforward answer to this anywhere.
I am considering using Mercurial for source control on a small (2-3 developers) project. I like the idea of not having to subscribe to a central repository, and I like that everyone effectively has a complete copy of the project. What I don't understand is how the Mercurial clients communicate changes to each other. Does it require opening a specific port or something similar?
Any pointers to help on Mercurial or comments from people who have used it would be gratefully received.
Mercurial can access remote repositories in a number of ways. The main ones are:
File access (i.e. look at the repo at this path)
HTTP / HTTPS (i.e. look at the repo being served at this web address)
SSH (i.e. log into this machine / user, and look at the repo at this path)
The first only really works if your team is all working on a shared file-system, but is also useful if you personally have multiple clones that you want to move information between.
HTTP is how you would access something like Bitbucket, or some other "available to all" server. You can set-up a temporary server on a machine with the command hg serve, and that's useful if you need to share with a colleague quickly and don't care about security, but normally HTTP Mercurial servers sit behind Apache, or some other web server software.
An SSH based set-up is just a machine running an SSH server which has Mercurial installed. Mercurial logs on to the machine, and invokes hg remotely. The local hg and the remote hg then talk over the link. Very easy to set-up in my opinion. Credentials are all handled in normal SSH ways.
Further reading:Publishing Repositories
I am learning how I can install Mercurial on our team system, but I am not experienced enough to make some decision.
For our team, we have a server machine used as a repository. Every team member also has her/his own Linux RedHat installed machine. However, we do not do anything on our local terminals and we do everything on the server. Every member has a user directory on the server such as /home/Cassie, /home/john, ... and we save all our code and work there. When we turn on the local terminals, the GNOME system shows our personal files on the server not the local machine. Whenever everyone click the terminal application on desktop, it connects to her own home directory. Thus, we do not need to use SSH command to connect to the server. It is like the school multi-users system. Everyone has a user account and she logs into her own account to do her own work. I hope I can install a shared repository on that server and every one can do push, pull, etc. all kind of commands there.
1) Since we use a shared environment, does it mean that I need to install Mercurial on only the server and that is enough for everyone to do "commit", "push", "pull", etc. commands?
2) By installing only system-wide Mercurial, does it eliminate the ability to do local commit? If I would like to let everyone still have the "local commit" ability, how should I do it?
3) I have searched online. Some people mentioned that for a shared network server, it is impossible to have locks for any two users if they are trying to access the same file at the same time. Does it imply my situation?
In sum, we do all the work on the server. I hope to find a plan to have Mercurial control on a repository shared by everyone when everyone still has local commit ability and the repository still has some locks protection if any two users try to access a file at the same time. If this scenario is feasible, can I just install the Mercurial on the server or I need to install Mercurial for both servers and users machines? If it is impossible for the scenario, would someone please suggest me a plan to have version control for our system?
1) Since we use a shared environment, does it mean that I just need to install the Mercurial on the server and it is enough for everyone to do "commit","push","pull"..etc commands ?
If your users are logging into a shell on the server in order to do their work, then yes it is sufficient to have Mercurial installed only on the server.
2) By installing only system-wide Mercurial, does it eliminate the ability to do local commit ? If I would like to let everyone still have the "local commit" ability, how should I do it ?
Your users will presumably checkout from a shared "root" repository into their own home directory in order to work on the code. They will have a "local" copy of the repo in their home directory and will push into the shared root repository.
3) I have searched online. Some people mentioned that for a shared network server, it is impossible to have locks for any two users if they are trying to access the same file at the same time. Does it imply my situation ?
As long as your users are working within their own local copies of the repo, they will not interfere with one another. The only time a conflict may arise is when committing back to the shared root repository -- in which case the user will need to merge their changes and resolve any conflicts.
I would recommend reading carefully through Joel Spolsky's excellent Hg Init tutorial for a better understanding of how Mercurial handles "central" and "local" copies.
I would like to host my own version control on the server I already pay for. I don't have shell access, but I can use ftp (obviously) and mysql. Are there any version control solutions that can run with only these?
I don't think Subversion or CVS will work without software installation. Can you mount your account as a file share/network drive? If so Mercurial would work. You could keep your master repo in the folder and clone it onto your local hard drive for real work. If you're just looking for a remote repository solution, you might be able to use Mercurial or Git with DropBox in the same way.
This is just my opinion, but if any provider ever told me they don't support SSH because of security I would immediately cancel my account and get a new provider. Let me guess: they only do Windows server hosting?
If you need to keep your project private you could always use a paid GitHub or BitBucket account as well, but that doesn't solve the problem of hosting on your existing account.
Straight out of git's man page:
Git natively supports ssh, git, http, https, ftp, ftps, and rsync protocols.
Rsync works over FTP, so you could have a local folder that represents what you want on the host, and then use rsync to deploy it.
I'm a big fan of backing things up. I keep my important school essays and such in a folder of my Dropbox. I make sure that all of my photos are duplicated to an external drive. I have a home server where I keep important files mirrored across two drives inside the server (like a software RAID 1).
So for my code, I have always used Subversion to back it up. I keep the trunk folder with a stable copy of my application, but then I create a branch named with my username, and inside there is my working copy. I make very few changes between commits to that branch, with the understanding that the code in there is my backup.
Now I'm looking into Mercurial, and I must admit I haven't truly used it yet so I may have this all wrong. But it seems to me that you have a server-side repository, and then you clone it to a working directory in the form of a local repository. Then as you work on something, you make commits to that local repository, and when things are in a state to be shared with others, you hg push to the parent repository on the server.
Between pushes of stable, tested, bug-free code, where is the backup?
After doing some thinking, I've come to the conclusion that it is not meant for backup purposes and it assumes you've handled that on your own. I guess I need to keep my Mercurial local repositories in my dropbox or some other backed-up location, since my in-progress code is not pushed to the server.
Is this pretty much it, or have I missed something? If you use Mercurial, how do you backup your local repositories? If you had turned on your computer this morning and your hard drive went up in flames (or, more likely, the read head went bad, or the OS corrupted itself, ...), what would be lost? If you spent the past week developing a module, writing test cases for it, documenting and commenting it, and then a virus wipes your local repository away, isn't that the only copy?
So then on the flip side, do you create a remote repository for every local repository and push to it all the time?
How do you find a balance? How do you ensure your code is backed up? Where is the line between using Mercurial as backup, and using a local filesystem backup utility to keep your local repositories safe?
It's ok thinking of Subversion as a 'backup', but it's only really doing that by virtue of being on a separate machine, which isn't really intrinsic to Subversion. If your Subversion server was the same machine as your development machine - not uncommon in the Linux world - you're not really backed up in the sense of having protection from hardware failure, theft, fire, etc. And in fact, there is some data in that case that is not backed up at all - your current code may exist in two places but everything else in the repository (eg. the revision history) only exists in one place, on the remote server.
It's exactly the same for Mercurial except that you've taken away the need for a separate server and thus made it so that you have to explicitly think about backing up rather than it being a side-effect of needing to have a server somewhere. You can definitely set up another Mercurial repository somewhere and push your changes to that periodically and consider that your backup. Alternatively, simply backup your local repository in the same way that you'd back up any other important directory. With you having a full copy of the repository locally, including all revision history and other meta data, this is arguably even more convenient and safe than the way you currently do it with Subversion.
The "hidden" .hg directory stores all of the local commits. You can back up this directory using a standard backup program.
The changes get to the remote directory only when you push. Commits stay local, but you get them if you clone your repository. Then, yes, if you want your things to get to the server repository you have to push to it "all the time".
On the other hand, nothing stops you to have several machines and push content from one to another. Every mercurial repository can turn itself into a server in a matter of seconds typing "hg serve".
I'm not sure it really answer to you question, but I too am a big fan of backup and manage things this way with many clones of my repository (I also use massively mq to work in patch mode but that's another story).
PS: as a sidenote, I'm considering to use mercurial as a tool for filesystem backup. The only thing that bother me is that for this purpose I would prefer to disable the diff feature and treat all files as binary, but that should be easy.