tags:

views:

98

answers:

2

I'm going through Bitbucket and I can't seem to find any Mercurial repositories that look like what I suspect our repository would look like, provided we switch to Mercurial.

As such, I'm wondering, is there a workflow that we're not considering here?

The thing I'm talking about is that I did a small automated test. We're 14 people that work on the same project, split into 4 scrum teams. To simulate 14 (I picked 10, round number) people working in parallel on the code, using Mercurial DVCS, pushing to the same central master repository, I wrote a script.

  1. I created a new "master" repository, and then cloned it for 10 virtual people
  2. I then ran a 1000 iteration loop, picking a random clone, and doing one of the following:
    • 10% of the time, do a pull from master, merge, commit merge, and push
    • 90% of the time, do a local change and commit

Note that I ensured that there would never be merge conflicts by simply making each virtual person work on his own file.

This would simulate people working locally by doing 1+ commits before pulling, merging, and pushing (to avoid 2+ heads in the master repo). It might be that this workflow is wrong.

This is a sample of what the repository now looks like (screenshot + link to repo):

sample screenshot from TortoiseHg

The repository can be found here: http://hg.vkarlsen.no/hgweb.cgi/parallel_test/graph.

This looks awfully messy, and as I said, I can't seem to find any repositories that have similar history. By "messy", I mean that it looks like older history of the project will almost always have 10 parallel branches. Close to the top, it tapers off of course, but it will expand as people that are currently working in their local repository pushes to the master.

So I have two questions:

  1. Can anyone show me a repository that has similar history? Since I can't seem to find any, I'm starting to wonder about what kind of conclusions I can draw from that...
  2. Is there something wrong with our workflow (that is, the workflow I've laid out here)? Should we rebase/squash/transplant, delegate push responsibility to one person, other things, instead of the way it was done here?
+7  A: 

Impressive preparation!

  1. It always looks messy if you go back a bit and look at all old commits at the same time. It always tapers of, even looking at a small bit old history. See http://hg.intevation.org/mercurial/crew/graph/12402?revcount=120 for instance. This is not the most recent commit, but shows all history up to that commit.

  2. Rebase helps quite a lot, especially if persons are working on separate areas. (I usually check the incoming commits to see if there are potential file or functionality conflicts, and if not, I do rebase.)

Rebase is not fool-proof though, so merge is the preferred "safe" action, but it leaves more "garbage" in the history. A trade-off.

Rebase is sort-of like the bog standard SVN update. The existing stuff is made baseline and your changes go on top, cross your fingers it still works. It's useful, but there are times when you feel safer having yours, theirs and the merge as separate commits in the history.

There is also commit-squashing as an option (histedit extension maybe), which squashes all in-between commits to one. This is useful when you're about to push and want to transferring many partials commits in your own repo as a single commit to the main.

Marcus Lindblom
Ok, then this is not way off base. I was kinda wondering if everyone else was doing patch-emails to a central maintainer or whatnot, but that repo you're linking to shows me the same thing. Good. Next stop is to evaluate Kiln (from Fogcreek) as our website, with its Electric DAG it should be easy to see which commits contributes to which other commits, which might make older history much easier to use.
Lasse V. Karlsen
Didn't know about the electic DAG. Will look at Kiln more. See also http://stackoverflow.com/questions/3879856/is-there-any-way-to-change-how-graphs-are-represented-in-mercurial about improving graph display.
Marcus Lindblom
+4  A: 

I have 12 developers working in the same Mercurial repository at work, and our history looks nothing like that. There are occasional merge commits, but most merges are from merging actual branches, i.e there might be a merge in our main development branch bringing in changes from a bugfix release made on the production/release branch.

This is very easy to achieve, developers hack and commit to their local repository and when they have something stable enough to share with the rest of the team they push.

If nothing has been committed since they started committing the push goes through without problems.

If someone else has committed a change, Mercurial complains that the push will create remote heads. The developer then does a hg pull --rebase and retries the push. The push goes through and everyone is happy.

If you are using continuous integration with developers regularly pushing to a shared repository, this is the way to go. Knowing whether you have pushed changes or not is easy and you avoid lots of useless merge commits cluttering up your history.

Joakim Hårsman
"rebase", must look into that one.
Lasse V. Karlsen
Yes, rebase is really the key tool to make the history nice and linear. In Mercurial itself, we do an implicit rebase with the way we accept patches on the mailinglist and I do an explicit rebase when I have changesets locally that I want to push. We almost only merge when changesets were pushed to two different public repositories in parallel, e.g., when Matt pushed something to his repository and I pushed something else to the crew repository without noticing his push. The reason is simply that you shouldn't rebase published changesets, so we merge instead.
Martin Geisler