A pretty good description of how Mercurial handles this: http://stevelosh.com/blog/2010/02/mercurial-workflows-branch...