Boost logo

Boost :

Subject: Re: [boost] [git] Mercurial? easy merging in svn, how about git/hg?
From: Martin Geisler (mg_at_[hidden])
Date: 2012-03-28 16:49:51

Frank Birbacher <bloodymir.crap_at_[hidden]> writes:

> Am 21.03.12 12:12, schrieb Philippe Vaucher:
>> To be honest, I feel that all the people that "cannot see the
>> advantages of a DVCS" are people who either didn't try it, or tried
>> it just enough to reassure themselves it wasn't worth it. Any tool
>> can suck if you're not willing to *really* see what it's worth.
> I feel you didn't try enough of svn: creating a branch and merging it
> back is really a simple thing to do in svn.
> cd someemtpydir
> svn co svn://server/svn/trunk .
> # create branch:
> svn cp ^/trunk ^/branches/my-branch -m "branch"
> # edit branch:
> svn switch . ^/branches/my-branch
> echo "new" > new.txt
> svn add new.txt
> svn ci -m "new file"
> # switch back to trunk and merge:
> svn switch ^/trunk .
> svn merge ^/branches/my-branch .
> # revise working copy before commit, or revert and try again
> # svn revert -R .
> svn ci -m "merged branch"
> So how would that go with git or hg? Would it be easier?

The equivalent Mercurial commands would be:

  hg clone http://server/repo
  cd repo
  # create branch similar to a SVN branch
  hg branch my-branch
  echo "new" > new.txt
  hg add
  hg ci -m "new file"
  # switch back to 'default' branch
  hg update default
  hg merge my-branch
  # revise working copy before commit, or re-try merge
  # hg resolve --all
  hg ci -m "merged branch"

So, it's very similar for this example. But don't you need to add a
--reintegrate flag if you want to merge your branch several times? It's
mentioned here
that "Once a --reintegrate merge is done from branch to trunk, the
branch is no longer usable for further work.". Neither Git nor Mercurial
has has such a flag and both let you keep working with your branches
after merging them (in any direction).

Could you try repeating the above commands with a rename in your branch
and an edit in trunk?

This is a full example (from

  cd /tmp
  rm -rf svn-repo svn-checkout
  svnadmin create svn-repo
  svn checkout file:///tmp/svn-repo svn-checkout
  cd svn-checkout
  mkdir trunk branches
  echo 'Goodbye, World!' > trunk/hello.txt
  svn add trunk branches
  svn commit -m 'Initial import.'
  svn copy '^/trunk' '^/branches/rename' -m 'Create branch.'
  svn switch '^/trunk' .
  echo 'Hello, World!' > hello.txt
  svn commit -m 'Update on trunk.'
  svn switch '^/branches/rename' .
  svn rename hello.txt hello.en.txt
  svn commit -m 'Rename on branch.'
  svn switch '^/trunk' .
  svn merge '^/branches/rename'

I get a tree conflict from the merge:

  --- Merging differences between repository URLs into '.':
  A hello.en.txt
     C hello.txt
  Summary of conflicts:
    Tree conflicts: 1

All of Bazaar, Mercurial, and Git agree that the edit of 'hello.txt'
should be merged into 'hello.en.txt' and that there's no conflict here.

This merge bug has been there since Subversion 1.5, and it isn't fixed
in version 1.6.17 (the most recent packaged version for Debian). It's
also mentioned in version 1.7 of the SVN book:

Martin Geisler
Mercurial links:

Boost list run by bdawes at, gregod at, cpdaniel at, john at