How to use Mercurial as a single developer?

I decided that I want to use Mercurial for a small personal project.

Most of the help I read about is about merging changes between multiple users. Since I am solo, this will not happen.

Should I have multiple repositories? My development computer is already backed up on my Windows Home Server, so it makes no sense to have a second repository in other places for backup purposes only.

Should I fork every day? Or just around releases? Or when?

In general, what practices do you recommend for a single developer using Mercurial?

+62
version-control mercurial
Nov 10 '08 at 6:34
source share
13 answers

I use Mercurial to develop FsCheck, a unit testing system hosted in code. I am currently the only developer, but sometimes people send me patches.

Specifically, I have one folder on my file system called "FsCheck". In this case, I have one repository and therefore a folder called main. As a rule, I have several folders next to where I work on certain functions or bug fixes or something else, say, about exception errors and faultless validation and correction of userFoo. They are created using the hg clone.

When I am done with a function or fix, I do everything in this folder and click on the main one. Perhaps the merger is mostly. (hg commit, hg push, hg merge). Then I delete the folder (carefully using hg status and hg outgoing so that I don't discard something useful).

I almost never work mostly except right before the release, where I do the final cleanup (e.g. documentation). Before the release, I mark the main release number (hg tag v0.5.1).

Codeplex uses svn as a sourcecontrol. I use it only to store releases for which I use a locally verified working copy of SVN, to which I copy the Mercurial repository using the hg archive. Then run the svn command. Primitive, but it works (using Mercurial as an SVN “super-client” on windows until it’s very user-friendly)

I have not had to perform maintenance on previous releases, but I would have done this by cloning the main repository from this version (this is easy since I tagged it) and I work in this separate repository. Merging with the main highway would be as simple as pushing the changes to the main and merging.

In short:

  • One folder for storing all project repositories with the name of your project
  • This folder contains one primary repository and one temporary repository per “unit of work” with a descriptive name for the unit of work.

It's good that your branches and what you are working on are intuitively visible on the file system.

+35
Mar 01 '09 at 17:39
source share

From the way your question is formulated, I think that you may have some misunderstandings related to version control terminology.

You must have one repository for each project. You can view the repository simply as a folder in the file system. When you initialize the Mercurial repository in a specific folder, each file in this folder and any of its subfolders can be added to the repository for version control. You do not have to add everything, but any of them will be added if you want.

You can drag this local repository to a remote repository if you want, either as a backup form, or as a way to share code with others. But if this is just a personal project, it most likely will not be needed, especially since you already have a backup solution.

Branches are commonly used to distinguish between different "versions" of a project. As some people have noted, this can be useful as a solo developer to test the code refactoring method or test a different approach to a specific problem. If this does not work, you do not need to worry about figuring out where to lean back, just light a branch. If this worked, you merge the branch back into the main repository ("trunk") and continue.

If you get to the point of making “releases” of code, and you need to continue to maintain older versions, you will also want to use branches. For example, imagine you are releasing version 1.0, and some people are starting to use it. Although they use it, you are privately continuing to work on the next release, possibly 1.1, adding features to your trunk repository. Now, someone finds an error in the released 1.0 code that you need to fix, but you cannot just fix it in the trunk and give them that code because it cannot be released. This is where you need the 1.0 branch. You can fix the error in the 1.0 branch and merge the patch correction in the trunk so that the error is also fixed there. You can then repackage 1.0 using the fix and get it for your users, without thinking about how to get the trunk in a state that can be released to the public.

Other than that, there is usually not much fancy work involved in using the Mercurial solo. Do some work, and when you finish the function, instruct her to give yourself a “breakpoint” at which you can return in the future if necessary. You do not need to do it every time you save or something like that, just do it when you feel that you have added something somewhat meaningful. This will give you a pleasant project history if you ever need to look back.

For more information, I highly recommend spending some time reading this book: Distributed Version Control with Mercurial . You do not need to read extended topics, but reading at least chapters 1-5 and 8 will give you a good introduction to Mercurial and version control in general.

+29
Feb 24 '09 at 7:21
source share

I use Mercurial daily, see here , I also help in one of the few free hosting services supporting Mercurial, ShareSource (I'm on the credits page). I use HG since Xen dropped BitKeeper.

I would advise you, for personal projects, to avoid branches at all costs. Mercurial idea that the industry is a little different from what you expect. Other systems, such as Git, facilitate branching (and the scientist's crazy ideas). However, I use Git when I need light, cheap branches.

My typical day with hg:

(See where I left off) # hg status (See what I was doing with foo) # hg diff -r tip src/foo/foo.c (Finish one module, commit it) # hg commit src/foo/foo.c (Push changes) # hg push 

Merging is also quite simple, as well as pulling specific changes from related repositories. But, if your solo, most likely, if you get the submitted merge for permission, you probably messed up without updating the remote repo.

I started some solo hobby projects that became wildly popular a year after I released them, I'm glad I used HG. Its syntax is close to subversion, its very intuitive and extremely portable.

Of course, yes, I use Git and SVN .. but not for personal projects. A note on my repo index (link posted), I rewrote hgwebdir in PHP because I wanted to easily change its appearance and pull RSS from each repo.

In short, for personal use you will find it VERY friendly. Posts, tags, etc. Simple .. avoid branches if you really need them.

This is a tutorial that I wrote some time ago describing how to use Mercurial to manage a website , it may seem interesting to you when setting up your keys, hgrc, etc.

+6
Feb 24 '09 at 7:48
source share

I use a different distributed version control system than Mercurial, but I doubt it is important for this.

In my solo projects I use branching quite intensively. Usually I have a main development branch ("trunk"), which should have a working version at any time. By this I mean that unit tests and other automated tests pass, and that all code is checked by these tests, with the exception of small bits, which I explicitly excluded from the scope of testing. This ensures that the trunk is always in good shape for further development.

Whenever I start work on a change, I create a new branch from the branch branch. It gives me the freedom to hack freely. For example, I can not worry about the automatic tests taking place in this thread. Since this is an isolated area, I can do it as often as I like, and I do it: microcommands are my favorite feature with distributed version control. When the work in the branch is finished, I will combine it back into the trunk.

The advantage of this style of work is that if it turns out that the changes I'm working on are bad ideas, I can easily backtrack. In fact, there is nothing to backtrack because the changes have not been merged.

Sometimes I am lazy and do not create a new branch for some new thing that I am developing. It always turns out that this is a mistake when I need more time than I expected to finish the job. It gets worse when I need to make another, unrelated change in the middle of it. When I follow the all-work-in-its-own-branch style, unrelated changes can be made in its own branch, merged into trunk, and then another branch can merge the change from the outside, if necessary.

+5
Feb 24 '09 at 7:44
source share

They are usually the same as for any software project. Just the presence or absence of version control is beyond the scope of any discussion;)

Usually you just commit when your function is ready. Since you have a backup, you do not need to do it every day, just to keep your work safe.

For branching: in my solo project, I use it mainly to search for ideas, for example. when I have another solution for the same problem. For this, I also like the Git stash command.

However, I do have some repositories. I have a shell access hosting that I click on. Therefore, I can synchronize with this repo no matter where I work, and on whatever workstation I have (at work: when I have time for code, at home and at work, when in my parental home).

+3
Nov 10 '08 at 7:01
source share

I do not know why you need several repositories, since you are already creating a backup of your computer on which the repository will be located.

And, perhaps, you will branch out for yourself if you want you to explore the function, and do not want to scramble your main code branch.

But perhaps you will extract something from the question I posed earlier.

+2
Nov 10 '08 at 6:50
source share

I used CVS, Perforce, Subversion before as my personal version control system and went to Mercurial two weeks ago :-) At work we use MS Team System ...

For me, the most noticeable new thing is the easy transfer between different machines. At work, I have material in a mercury repo (using hg as a Super Client against Team System). I regularly push / pull all changes to / from my laptop, so I have a complete history on both machines.

At home, I also push / pull the repo from the laptop.

As a result, I can work wherever I am (home office using a computer muscle, on the road using a laptop or at work), and don’t worry if I lose the change. Ok, sometimes I need to combine two changes, but it rarely hurts ... hg does it pretty nicely IMHO.

In addition, the "installation cost" with mercury is quite low. You read the tutorial, install it, say "hg init" and continue to work. No more errors if something belongs to your sacred SVN server, where to put it and so on. Mercury "friction" is slightly lower than SVN.

+1
Mar 03 '09 at 14:20
source share

I think it depends on whether you support an existing application and add features (or fix big bugs) at the same time.

Thus, you can fix errors in the main branch by creating a new function in your branch.

I do just that with my applications, but with a local version of CVS. Also, if a new developer is added to your team, you should all go.

I agree that this is a separate issue from the backups.

Good luck
Randy Stigbauer

0
Nov 10 '08 at 19:46
source share

SCM is a kind of "smart" undo buffer extension for your editor. You can go back, you may have solved the problem, but deleted it because it was reorganized, but you will need a solution again, etc. Set up a visual diff and it will tell you what you have changed since the last commit or in the last two days, I constantly review my code and change it if I don’t like my old solution.

Branching works on threads: when you start going in one direction, but it needs to think more, and in the meantime you would like to work on something else, then this can help.

Beware that DVCS treat the repository as a whole. You can transfer file by file (using filters), but they save the changes throughout the repository. This confuses cvs (svn) users where changes to a single file are more regular.

0
Nov 17 '08 at 4:04
source share

Another great reason to have multiple clones (at least if you have more than one computer) is because you can pretty easily see if you made any dependencies to your code. (For example, your code will be run on another computer, which may not have all the development packages that are on your main workstation)

0
Feb 19 '09 at 11:55
source share

I suggest you read this link , which describes the various ways to implement SCC and the choice of method that mainly suits your needs.

0
Feb 27 '09 at 7:06
source share

DVC, such as Mercurial and Bazaar, and Git, have made many things cheaply available so that an army of one can take advantage of advanced features.

  • You can quickly experiment with the “throw away” code if you keep the discipline in the branches up to date or off-highway and synchronize all your deltas meaningfully in the DVC.

    The code just flows without worry, and it can actually provide mental freedom to try a few before installing on your preferred option.

  • Some people create branches for everyone that they implement (especially in git), no matter how small or large. In mercury, this approach to development is cheap, so why not use the opportunity? Thus, this may mean tiny commits with larger commits occur several times a day.

    but. If you take this approach, you might want to click on the changes to the off-host repository at the end of the day to cover the time between work done during the day and the time when the backup is to WHS.

    b. I installed CopSSH on my WHS and it works great by providing SSH / SFTP / SCP functionality to a ~ 5 MB window window. Before that, I had been running Ubuntu Linux on Virtual Server 2005 to provide, among other services, similar functionality. You can push your Mercury to the WHS field on top of ssh

0
Mar 02 '09 at 8:38
source share

I always use Git or Mercurial, even one.

I share repositories when I want to make some reusable components available to other projects. I am set to when I commit, it automatically clicks (I did it with the Tortoise HG plugin) because sometimes I forgot to click, and when I move geographically, I need this code, understand?

So these are my tips.

0
Nov 16 '10 at 18:35
source share



All Articles